homepage Welcome to WebmasterWorld Guest from 54.243.17.133
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Browsers / Firefox Browser Usage and Support
Forum Library, Charter, Moderators: incrediBILL

Firefox Browser Usage and Support Forum

    
Firefox trouble - it never finishes loading
tores




msg:1589878
 2:03 pm on Jan 17, 2005 (gmt 0)

Hi all

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

 

tores




msg:1589879
 3:22 pm on Jan 17, 2005 (gmt 0)

Have done some testing around this and narrowed it down to the following code:

<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

BlobFisk




msg:1589880
 3:49 pm on Jan 17, 2005 (gmt 0)

How about using
innerHTML instead?
tores




msg:1589881
 4:19 pm on Jan 17, 2005 (gmt 0)

How do I use InnerHTML? Can u show me an example?

BlobFisk




msg:1589882
 4:35 pm on Jan 17, 2005 (gmt 0)

You will need to create your popup and write the main elements out (html, body etc.), but useage would be:

document.getElementById('bodyID').innerHTML = '<p>Hello World</p>';

HTH

tores




msg:1589883
 4:49 pm on Jan 17, 2005 (gmt 0)

Tried innerHTML but that gave the same result...
Maybe it's a just a bug in FF...

rocknbil




msg:1589884
 5:11 pm on Jan 17, 2005 (gmt 0)

This is most likely your problem:

<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 . . . .

tores




msg:1589885
 5:25 pm on Jan 17, 2005 (gmt 0)

document.close()... That was it:)

Thanks a lot. IE is nice in the way that it forgives and corrects many of your mistakes, but with FF one actually is forced to produce correct code, and in doing so learning new stuff:)

gmiller




msg:1589886
 7:15 am on Jan 18, 2005 (gmt 0)

There's a third alternative that wasn't mentioned above, the DOM appendChild() function and its relatives. Unlike innerHTML, they have the advantages of being fast and standard-compliant. innerHTML is an obsolete IE property that's been picked up by a few other browsers.

The main drawback is that createElement(), appendChild(), etc. are a little more complex to use.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Browsers / Firefox Browser Usage and Support
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved