Forum Moderators: open
Up till recently I was developing a site in IE. Now i've switched to Firefox, and have encountered some strange faults. One of them is a popupwindow where I use javascript to populate it. IE have no problems displaying the window and it's contents. FF displays the window, but in the statusbar it says "transferring data..." forever as if all of the page couldn't be read from the server...
This is somewhat anoying as I wish to probe the html-source with FF's view page source, and this is impossible until the page is fully loaded.
regards tores
<script language="Javascript">
win=window.open("","id","status=yes,width=300,height=300");
win.document.write('<html>Hello</html>');
</script>
Firefox prints "hello" but stops loading the page after that, when the "load-bar" on the statusline is only about 33% filled...
regards tores
<script language="Javascript">
win=window.open("","id","status=yes,width=300,height=300");
win.document.write('<html>Hello</html>');
win.document.close();
</script>
When you write to a document closing the document flushes the buffer and prints to the document, it's a very common mistake for new coders. If you load an actual PAGE in the URL parameter, you don't need to close it.
While we're on it this is something you probably want to add:
<script language="Javascript">
var day = new Date();
var id = day.getTime();
win=window.open("",id,"status=yes,width=300,height=300");
win.document.write('<html>Hello</html>');
win.document.close();
</script>
Note the removed quotes around id because it is now a variable. With your previous code, every "new window" called by this method would open in the SAME window. Assigning a relatively unique ID to the window forces a NEW one to open each time.
The reason this is important is if you're calling the same sub from various pages and the user leaves the initial pop-up open, the'll click new pop-ups and it will appear that "nothing happens" even though it's loading in the initial new window, which is now behind the current window . . . .
The main drawback is that createElement(), appendChild(), etc. are a little more complex to use.