Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onLoad issue

Status
Not open for further replies.

disord3r

Programmer
Apr 12, 2002
189
US
When viewing my page in Netscape 4.7 (and I'm assuming anything prior), I noticed that my onLoad isn't working. It calls a function that initializes the navigation on my page, like so:

<body ... ... ... ... onLoad=&quot;start_nav();&quot;>

The things that are supposed to happen inside start_nav() never happen, so this is why I say it's not &quot;working&quot;. No errors, but no functionally-correctness.

If I put commands in there that 4.7 doesn't understand (document.layername.style.visibility=&quot;hidden&quot;;), it tells me that there's an error on the page, so I know it's aware of the function and compiled or syntax-checked it (or whatever you call what it does as the page loads).

IE6, NS7, Mozilla, Opera; all are fine. NS4.7 just isn't having the onLoad thing. Searching the web, I came across a suggestion to put a script tag later in the page to call that function, like so:

<script language=&quot;Javascript&quot;>start_nav();</script>

...but that, too, fails. Again, no errors, but it's just not starting my navigation. And tips or tricks to get this thing going?
 
i would put an alert in the function to see if it's getting called:

function start_nav() {
alert(&quot;In start_nav()&quot;);
// ...the rest of your function...
}

show us the entire function start_nav() so we can check for errors =========================================================
if (!succeed) try();
-jeff
 
Jemminger,

I am working on a web page where I had planned to use the <body onLoad=&quot;.. event to trigger a function that I needed but it fails.

After searching Tek-Tips, I found this problem exactly in this thread: thread216-468682 tried the solution suggested but it is not triggering the onLoad event.

My script snippets look like

<head>
<script
language=&quot;JavaScript&quot;
type=&quot;text/javascript&quot;>
<!--
function initval() {
// Sets the Suffix fields initially to disabled to prevent random selections
alert(&quot;got here.&quot;);
clrchkbx01();
clrchkbx02();
clrchkbx05();
clrchkbxCH03();
alert(&quot;got here.&quot;);
}
-->
</script>
</head>

<body onLoad=&quot;javascript:initval();&quot;>

I also went and changed the <body> to read:

<body onLoad=&quot;initval();&quot;>

AND

<body onLoad=&quot;alert(&quot;got here.&quot;>

And they failed too.

Suggestions?
DougCranston


 
xutopia,

Sorry, if my note sans my environment might have caused your note. My environment, will be primarily will be IE5, with some mix. Although it is an intranet site, and we do have standards set for IE5.5 or greater we do have some users out there with NS.

Thanks for the reference.

DougCranston
 
doug,

Well since you ask that IE users be above 5.5 why not ask Netscape users to use at least at version 6?

Gary Haran
==========================
 
xutopia,

One can ask, but one cannot dictate unless they are in your part of the organization. Those that are in my department have IE5.5. Those outside...use what they please sometimes even when we have a corp standard.

If I design to exclude then I design to shoot myself in the foot. I may not like it but one either deals with reality or one finds a job elsewhere in our org.

DougCranston
 
doug,

are you saying you're using IE5+ and the onload event is not firing?

if it is NS4 that is not firing, about all i can think of would be to call the function right before </body> to approximate onload.





=========================================================
while (!succeed) try();
-jeff
 
jemminger,

Yep.. Testing on IE5.5...

Just figured out a work around, not as pretty but works.

Checked all my reference books and have searched Google and everything seems to indicate that IE4 and > should handle but nope... I have tried it on three separate systems, 1 NT and 2 Win2000, all running IE5.5 SP2.

Thanks for asking.. As you have seen before, I attract the weird problems... Just the way it happens sometimes.

Have a great weekend with what is left of it. Have an all day staff mtg on Sun and Mon. Now there is a way to start your week off on the wrong foot.

Thanks again.
DougCranston
 
i have never experienced problems with onload in ie...make sure all your tags have closing tags...<html></html> etc...

have you tried assigning it via script? e.g.

window.onload = function foo() {
alert(&quot;foo&quot;);
}

could be a corrupt install of the browser...



=========================================================
while (!succeed) try();
-jeff
 
jemminger,

Had not thought of that... But, I will now show my ignorant of how to apply this approach self, and ask &quot;how and where would I place that?

The only place I could imagine this code dropping in the

window.onload = function foo() {
alert(&quot;foo&quot;);
}

code simply be placed in the <head><script>code here</script></head>?

Or where..

I don't know if it is the hour and day, but the ole brain ain't working.

Thanks,

DougCranston
 
hi doug,

it can be placed anywhere. one caveat: it will override anything you have in <body onload=&quot;&quot;>

if you need to add multiple functions to window.onload, i've created an easy method of doing so - check out thread216-518649





=========================================================
while (!succeed) try();
-jeff
 
jemminger,

Got it. Will test tonite after our staff meeting.

Thanks,
DougCranston
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top