954,598 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

<Body onload= > question

Hi there,

I have some java script menus created and I'm calling them from the tag as follows:

Because of this, the menu is the last thing to load on the page. I want it to be the first thing to load. Anyone know what I can do?

Thanks for any help,
Maj

maj
Newbie Poster
1 post since Mar 2005
Reputation Points: 10
Solved Threads: 0
 

instead of sticking it in the body onload, have you tried calling it in the header of the page:

<HTML>
<HEAD>
<SCRIPT LANGUAGE="Javascript">
function some_function()
{

}

some_function();
</SCRIPT>
</HEAD>
<!-- The Rest Of The Page -->
Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

Hi there,

I have some java script menus created and I'm calling them from the tag as follows:

Because of this, the menu is the last thing to load on the page. I want it to be the first thing to load. Anyone know what I can do?

Thanks for any help, Maj

call this function at the javascript section under head tag.


function();

vivek vermani
Newbie Poster
6 posts since Oct 2005
Reputation Points: 10
Solved Threads: 0
 
function();

What language is that written in? It isn't HTML or XHTML because they use to call Javascript.

felgall
Junior Poster in Training
50 posts since Aug 2004
Reputation Points: 13
Solved Threads: 1
 

thats what they mean... you can call a javascript function from anywhere on the page, as long as it is in the script tags you describe.

alpha_foobar
Junior Poster
182 posts since May 2005
Reputation Points: 20
Solved Threads: 5
 

Most times code within onload needs to be there because it references elements of the page that need to be loaded beforehand in order to be able to reference them. Moving the onload code to anywhere else will probably result in "object expected" errors because the part of the page that the script references hasn't loaded yet.

felgall
Junior Poster in Training
50 posts since Aug 2004
Reputation Points: 13
Solved Threads: 1
 
What language is that written in? It isn't HTML or XHTML because they use to call Javascript.

its just html code ...............sorry for writing it like that.............my motive was to just guide the way it would work..................

vivek vermani
Newbie Poster
6 posts since Oct 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You