I'm creating a new window {newWin = window.open()}, writing to it {newWin.document.write(string)}, then wanting to save it through the browsers File -> Save As...
The hitch is that it's trying to save the parent document that created the new window, rather than the content of the new window itself. I'm sure there's some way to do this, but through the lack of sleep and being sick and everything else going on, I've only been able to search Google for about 6 hours the last couple days trying to find something, however nothing's really turned up. I've found one site that has the code I already have, and they do the same thing, but they claim you can save the new window,
quote:
You can click the NEW WINDOW button which will open a new browser window. The study will be displayed in the new window. Use the browser print and save commands (File/Print, File/Save As) on the NEW window.
However, if you go there and try it, when you save the new window, it actually saves the parent document.
What I have right now:
saveWin = window.open("", "saveinfo", "toolbar=no, directories=no, location=no, status=yes, menubar=yes, resizable=yes, scrollbars=yes, width=300, height=200, screenX=300, screenY=100, left=300, top=100");
saveWin.document.open(); //not sure if this line is neccessary
saveWin.document.write(Message);
saveWin.document.close();
Does there need to be something in particular as the first parameter of open()?
I've tried creating a seperate file on the server (not through this script or anything, just uploading it myself), using that as the parameter, and as long as I don't do a document.write() to it, it opens that file and you can save it like I want to. However, as soon as you write something to it, when you go to save, it tries to save the parent document.
Or maybe the second parameter? Though I'm not entirely clear on what it's for. You can pass things like "_blank" or "_new" etc, right? Essentially the target attribute in <a href>?
Or maybe there's a whole better way to accomplish what I need... Essentially take a String from a Java applet, open a new window of some sort with that String in it (Notepad would be ideal, possibly with something like: window.location = "view-source:" + window.location.href), so the user can save it as a .txt file, although putting it in a browser and using the built-in File -> Save As... there wouldn't be a problem.
Maybe with PHP? I'm not familiar enough with either JavaScript or PHP to know what level of interaction is allowed/capable between the two. ...Have Java pass a String to JavaScript which passes it to PHP which dynamically creates a page entirely independent of the original page with the applet... That looks like a rather obscure way to achieve this, but if it works, I'll take it for now, at least until I get a chance to do it right.
I suppose that's enough for tonight... Many thanks to any ideas any of ya'll might have,
LF