Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 139215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:23:42+00:00 2026-05-11T07:23:42+00:00

Application requests KML data through AJAX from server. This data is stored in javascript

  • 0

Application requests KML data through AJAX from server. This data is stored in javascript variables, and displayed in Google Earth plugin.

In javascript, how do I provide a link to download the KML data stored in javascript variable (as a string) without requiring a request back to server?

This link: http://forum.mootools.net/viewtopic.php?id=9728

suggests the use of data URI, but that probably won’t work across enough browsers for my needs. Probably simplest just to go back to server to get data again for download, but curious if anyone has pulled this off with javascript.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T07:23:42+00:00Added an answer on May 11, 2026 at 7:23 am

    Short answer: you can’t and still be platform independent. Most browsers just don’t allow javascript to manipulate the filesystem.

    That said, you might be able to get away with some very platform-specific hacks. For example, IE offers the execCommand function, which you could use to call SaveAs. If you did that within an IFrame that had the data you wanted to save, you might get it working — but only on IE. Other options (again, I’m going Microsoft specific here) include this Silverlight hack, or ActiveX controls.

    I think for full platform compatibility, you’re just going to have to suck it up and provide a server-side download option.

    [Edit] Whoops! I didn’t do enough due diligence when I went link-hunting. It turns out the Silverlight hack I linked to has a server-side component. Looks like you’re pretty SOL.

    [Edit2] I found a nice summary of browser compatibility for execCommand here. Although it lists question marks for the ‘saveas’ command, maybe that might be a good route for you after all. Worth a try, perhaps?

    [Edit3] Well, I decided to do a proof of concept of the approach I suggested, and I got something fairly simple working in IE. Unfortunately, I proved in the process that this approach will not work for Firefox and doesn’t appear to work in Chrome/Safari, either. So it’s very platform dependent. But it works! Here’s a complete working page:

    <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'   'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> <html xmlns='http://www.w3.org/1999/xhtml' > <head>     <title>Javascript File Saver</title>     <script type='text/javascript'>       function PageLoad() {         var fdoc = window.frames['Frame'].document;         fdoc.body.appendChild(fdoc.createTextNode('foo,bar,baz'));       }       function Save() {         var fdoc = window.frames['Frame'].document;         fdoc.execCommand('SaveAs', true);       }     </script> </head> <body onload='PageLoad();'> <h2>Javascript File Saver</h2> <iframe id='Frame' style='width: 400px;'>Noframe</iframe><br /> <button onclick='Save();'>Save</button> </body> </html> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 202k
  • Answers 202k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Have you tried catching a WebException and handling it appropriately? May 12, 2026 at 8:23 pm
  • Editorial Team
    Editorial Team added an answer It looks like you might be suffering in terms of… May 12, 2026 at 8:23 pm
  • Editorial Team
    Editorial Team added an answer It depends. PNG is better for crisp images with a… May 12, 2026 at 8:23 pm

Related Questions

In Spring MVC a Dispatcher servlet is used as a front controller to handle
I am learning Silverlight and WPF on my own to expand my programming base.
I've developed a mini HTTP server in C++, using boost::asio, and now I'm load
I have a service responsible for many tasks, one of which is to launch

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.