View Full Version : Image Trail script only works in quirks mode

01-04-2007, 12:18 AM
So I found this nice script while coming across templatemonster.com where when you hover over a small preview image a bigger image appears. According to the js file this is from javascriptkit.com but I couldn't find it there and had to figure out how to install it myself.

Everything worked nicely but then, after looking at the integrated error console in Fx (Extras > Error Console), I noticed that it's producing some kind of infinite loop or something like that on my page while it didn't on templatemonster.com. I found out that the error is caused by the doctype, hence with the browser in standards mode whereas templatemonster's site is in quirks mode and not having this error.

I've uploaded the relevant files for you to conveniently review the problem. The stripped-down-to-a-minimum HTML file (http://primacom.net/~k6531190/Template-Monster.html) demonstrates the issue. The error comes from the loader.js (http://primacom.net/~k6531190/Template-Monster-Dateien/loader.js). The console says that there's an error occuring while processing the values for the width and left properties and it's ignoring the declaration but somehow it seems to read it over and over.

As I said this is only happening if I have a doctype in the HTML document. Can anyone give me a hint on how to make it work without errors in standards mode?

Thanks a lot. :)

01-04-2007, 12:14 PM
Replace those lines:
elem.style.left = pos;
elem.style.width = len;with this:
elem.style.left = pos + "px";
elem.style.width = len + "px";and see if that helps.


01-04-2007, 12:39 PM
Oh yeah baby, that was it! Thanks a lot, man. :)