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
Probably it would be usefull (JSP variant):
private void printSaveStringButton(String fileName, String content) throws Exception {
//add new invisible container with write / save functions
out.println("");
//save string in js variable
String jScript = "\n" +
"var SaveHelper = {\n" +
" content : null,\n" +
" saveContent : function(filename, text) {\n" +
" text=(SaveHelper.content!=null)?SaveHelper.content:text;\n" +
" var doc = document.getElementById('xmlContentId').contentWindow.document;\n" +
" doc.write(text);\n" +
" doc.execCommand(\"saveAs\",true,filename);\n" +
" doc.close();\n" +
" }\n" +
"};\n" +
"SaveHelper.content = '" + org.apache.commons.lang.StringEscapeUtils.escapeJavaScript(content) + "';\n";
out.println("");
//add button that writes content into iframe container and show save dialog.
out.println("");
}