943,697 Members | Top Members by Rank

Ad:
Mar 25th, 2005
0

<Body onload= > question

Expand Post »
Hi there,

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

<body onload="initjsDOMenu()">

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
Similar Threads
maj
Reputation Points: 10
Solved Threads: 0
Newbie Poster
maj is offline Offline
1 posts
since Mar 2005
Mar 25th, 2005
0

Re: <Body onload= > question

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

HTML and CSS Syntax (Toggle Plain Text)
  1. <HTML>
  2. <HEAD>
  3. <SCRIPT LANGUAGE="Javascript">
  4. function some_function()
  5. {
  6.  
  7. }
  8.  
  9. some_function();
  10. </SCRIPT>
  11. </HEAD>
  12. <!-- The Rest Of The Page -->
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Nov 22nd, 2005
0

Re: <Body onload= > question

Quote originally posted by maj ...
Hi there,

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

<body onload="initjsDOMenu()">

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.
<head>
<javascript>
function();
</javascript>
</head>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vivek vermani is offline Offline
6 posts
since Oct 2005
Nov 26th, 2005
0

Re: <Body onload= > question

Quote originally posted by vivek vermani ...
<javascript>
function();
</javascript>
What language is that written in? It isn't HTML or XHTML because they use <script type="text/javascript"> to call Javascript.
Reputation Points: 13
Solved Threads: 1
Junior Poster in Training
felgall is offline Offline
50 posts
since Aug 2004
Dec 3rd, 2005
0

Re: <Body onload= > question

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.
Reputation Points: 20
Solved Threads: 5
Junior Poster
alpha_foobar is offline Offline
182 posts
since May 2005
Dec 3rd, 2005
0

Re: <Body onload= > question

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.
Reputation Points: 13
Solved Threads: 1
Junior Poster in Training
felgall is offline Offline
50 posts
since Aug 2004
Dec 5th, 2005
0

Re: <Body onload= > question

Quote originally posted by felgall ...
What language is that written in? It isn't HTML or XHTML because they use <script type="text/javascript"> to call Javascript.
its just html code ...............sorry for writing it like that.............my motive was to just guide the way it would work..................
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vivek vermani is offline Offline
6 posts
since Oct 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: Image for Clear Form
Next Thread in HTML and CSS Forum Timeline: Bookmark when closing browser.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC