Click to See Complete Forum and Search --> : Can I feed window.open() with a document string, rather than a URL?


karayan
06-25-2003, 03:49 PM
In trying to resolve prior issues with window.open(), I have come across this problem: I need to open a new window, and instead of feeding it with a URL [like window.open("file.htm");], I want to feed it an entire document string. That is, the entire HTNML code is in a string variable, so I want to pass that directly to open(), instead of a file URL.

<background problem>
The reason I am asking for this is that I need to open a file in a window, modify its HTML and THEN save the result as a web page through IE. The trouble is, IE saves the ORIGINAL file (source), NOT the modified document object. So, I thought I'd try reading the file into a string, modifying it and then passing the result to a wondow.open() in a new window. Then, the user would save the result as usual.
</background problem>

The only other way to solve my problem is to go to Visual Basic. I'd rather not learn YAL (=yet another language) :)

George

David Harrison
06-25-2003, 04:02 PM
I can't remember the code for it right now, but you could just create a pop-up window that looks like a normal browser window.

pyro
06-25-2003, 04:10 PM
Is something like this what you are looking for?

<script type="text/javascript">
newwin = window.open("","newwin","width=400,height=300");
newwin.document.write ("This is some content for the new window.");
</script>

karayan
06-25-2003, 04:20 PM
In reply to Pyro:

No, I'm afraid that doesn't work. If I do it:

newwin = window.open("", etc. etc.);

it opens an empty window. Then,

newwin.document.write("blabla");

adds the text "blabla" to the new window, BUT NOT TO ITS PAGE SOURCE, as loaded in IE. If you try to manually save the doc in the new window, it saves an empty file (becuase the page source is empty), even though currently the window is not empty! Go figure... :mad:

Any other ideas/tricks?

George

David Harrison
06-25-2003, 04:30 PM
What you could do is write the code twice in the new window, once as the page source and again in a text area on that new page so that if anyone wants to save the code, they can do.