Forum Moderators: open
Here's the href for the above:
<a href="javascript: largeview('view2.asp?name=merchandisepicture')">
<img border="0" src="merchandisepicture-t.jpg"></A>
How will it work if I move the script portion to the end? In a test, it seemed fine in IE, however if the page wasn't done loading, when I clicked on a thumb to show the large picture, the rest of the images for that page simply didn't load! Maybe a fluke with IE on my computer?
I have a similar question for the script code that runs a floating menu on my pages, but I'll post that in a different message.
Thanks
Shadows Papa
The best way to 'delay' execution of a script is to use <BODY ... onLoad="myscript();"> which waits for the page to finish loading and then runs your code.
In this example, you could put the "myscript()" function after your HTML content.
;)
If the page hasn't loaded fully, then all scripts that haven't been seen by the browser simply won't work.
As dcrombie states, the best policy is to have all scripts in the <head> section. Scripts that ought to be executed after the page has loaded is then called from the <body onload=""> You can call more than one script from there, but I'ld prefer to collect all such function calls in a meta call like this:
function main()
{
myscript1(parameter);
myscript1(parameter1,parameter2);
...
}
<body onload="main();">
On the other hand, I'm using scripts to dynamically generate menus, and these are loaded directly into place at the apropriate places in between the other html code. And on one page I'm enquiring about the number of entries in an array putting the result out on the page, and that piece of code is also placed directly within the other text.