Wednesday, 14 May 2008

FireFox double page load

OK... to anyone who's implementing a page counter.... if you find that the counter is doubling up when a request from FireFox (under OSX/Linux/doze) it's because the browser is loading the page twice. It's also due to how the W3C spec is written... and the behavior is entirely correct (if not a bit annoying).

If a browser find an IMG with an empty SRC tag then it should reload the page once more to check. I had an empty IMG SRC which was then dynamically assigned to with JavaScript.

To resolve the problem I just put a temporary image in place... which will never be seen because the containing div is hidden until the Javascript makes it visible again... at which point the correct image will be assigned to it.



Anonymous said...

It doesn't reload the page to check anything. It just tries to fetch an image and since the src attribute of the img tag is empty, it tries to use the page url for the image.

Tim B said...

It is not just this. Apache (created using PHP) spits back the following:

(title)ZK: Purchase(/title)
(!-- (meta http-equiv="refresh" content="40;url=view.php")--)
(!-- (link rel="stylesheet" href="kriss.css" type="text/css" media="screen" /) --)


we have a basket(a href="view.php")(img src="webgfx/en/sideBanner.gif" id="sideLogo")(/a)
(p) Your order:(/p) a real one
(p) Can be paid for and picked up at the KASSA/PHOTO counter. (/p)(p)Order number: 17(/p)


(I have changed angle brackets to normal ones, to show the html)
which works fine with Safari (that is where I copied it from) Firefox loads it twice. I have no empty src="" or any such thing. All ideas would be most appreciated!