Link to home
Start Free TrialLog in
Avatar of pingeyeg
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.
Avatar of alain34
alain34
Flag of United Kingdom of Great Britain and Northern Ireland image

If you want something to be executed straightaway, do not execute it from the onload event.

Could you provide your html code?
declare the js import in the <HEAD> section.
Avatar of pingeyeg
pingeyeg

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-Language" 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>
try to put them right after the
<body> tag
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);
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)!
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
Avatar of archrajan
archrajan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
Did my question make since?