pingeyeg
asked on
Loading first
Is there a way to make a .js document load first on the page? The reason I ask is because I got this lightbox effect from dynamic drive that works great, but you have to wait until the page completely loads before it will work.
declare the js import in the <HEAD> section.
ASKER
I have it in the head section, but it seems to not load until the page is finished:
<head>
<title>Welcome <%= Your_FirstName%></title>
<meta http-equiv="Content-Langua ge" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel="stylesheet" type="text/css" href="/dev/style.css" media="screen">
<script type="text/javascript" src="http://www.thecollegemates.com/dev/prototype.js"></script>
<script type="text/javascript" src="http://www.thecollegemates.com/dev/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="http://www.thecollegemates.com/dev/lightbox.js"></script>
</head>
<head>
<title>Welcome <%= Your_FirstName%></title>
<meta http-equiv="Content-Langua
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel="stylesheet" type="text/css" href="/dev/style.css" media="screen">
<script type="text/javascript" src="http://www.thecollegemates.com/dev/prototype.js"></script>
<script type="text/javascript" src="http://www.thecollegemates.com/dev/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="http://www.thecollegemates.com/dev/lightbox.js"></script>
</head>
try to put them right after the
<body> tag
<body> tag
ASKER
That didn't help.
the head section is executed first,
so your script gets loaded first.
but may be there is a window.onload event in the scripts that you are using, which may wait until the whole page gets loaded.
Event.observe(window, 'load', initLightbox, false);
so your script gets loaded first.
but may be there is a window.onload event in the scripts that you are using, which may wait until the whole page gets loaded.
Event.observe(window, 'load', initLightbox, false);
ASKER
That code is in the bottom of the page of lightbox.js. So what should I do to fix this?
does the code in lightbox.js depend on code that is loaded by the HTML page ?
the code is written in such a way that it has to be executed on the window load event.
i am not sure, if modifying that will help!
for example say that script tries to access a div element, which loads in the body.
when you try to load the script before loading the div, u will get errors, because the div does not exisit (it is not yet loaded)!
i am not sure, if modifying that will help!
for example say that script tries to access a div element, which loads in the body.
when you try to load the script before loading the div, u will get errors, because the div does not exisit (it is not yet loaded)!
ASKER
The only thing I know is that you have to put rel="lightbox[whatever]" to make the effect work on the image.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Makes since, but wouldn't that make it to where when an image gets loaded with that code in it the effect should work for that particular image?
ASKER
Did my question make since?
Could you provide your html code?