...

View Full Version : Writing to popUp window



JPM
07-17-2004, 04:36 PM
I am writing some text to a popup window, and before I write the text I use the myWindow.document.open() method, but it seems this doesnt work in netscape so the new text is just added to the text already there.
Is there another way to do this?

thanks

Willy Duitt
07-17-2004, 05:18 PM
Try writing the text at the same time you open the popup and not wait until it is already open....

JPM
07-17-2004, 05:55 PM
Thats what I do, but within the text I wrote when I opened the window there is a link, and when you click the the link I want to write some new text to the window/overwriting the text already there.

Willy Duitt
07-17-2004, 10:34 PM
Thats what I do, but within the text I wrote when I opened the window there is a link, and when you click the the link I want to write some new text to the window/overwriting the text already there.

If you want to overwrite everything in the popup use the popup name and write another document.write statement.

If you only want to replace a certain portion of the text use innerHTML...

JPM
07-17-2004, 10:43 PM
Thats what Im doing and I thought it would work, but it doesnt(unless I use popupwindow.document.open() before I write to it, then it works in ie.)

There is alot of other functions and stuff in the script so I guess maybe something else is causing the problem...

JPM
07-17-2004, 10:53 PM
If you want to overwrite everything in the popup use the popup name and write another document.write statement.

I tried it out with this simple script and it seems that if you just do another document.write it still adds the text to text already there..



<html>
<head>

<script>

var test = window.open("","test","width=200,height=200")
test.document.write("BLA BLA BLA BLA")

function wMore() {
test.document.write("BLA2 BLA2 BLA2")
test.focus()
}
</script>
</head>
<body>
<form>
<input type="button" onclick="wMore()" value="write" />
</form>
</body>

</html>


Anyway, I fixed it by putting all the content inside a div the first time then changed it all with innerHTML.

Willy Duitt
07-17-2004, 11:07 PM
While document.open() is assumed, you are not closing the document and therefore it is still open to write too....



<html>
<head>

<script>

var test = window.open("","test","width=200,height=200")
test.document.write("BLA BLA BLA BLA")
test.document.close();


function wMore() {
test.document.write("BLA2 BLA2 BLA2")
test.document.close();
test.focus()
}
</script>
</head>
<body>
<form>
<input type="button" onclick="wMore()" value="write" />
</form>
</body>


.....Willy

JPM
07-18-2004, 11:05 AM
Thanks! I was beginning to wonder after I looked it up in the js bible and it said the document.open() was supported by browsers.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum