Timewaster's Guide Archive
General => Everything Else => Topic started by: Skar on November 02, 2005, 01:31:59 PM
-
Ok. I'm about ready blow my top.
I've got the following code in my webpage:
<body class="body" onLoad="SetMenu()">
This triggers the javascript function SetMenu after the page is loaded. It works perfectly in IE.
Mozilla ignores it. Why? Surely such a vanilla functionality is duplicated in Firefox?
But for the life of me I can't figure out what it is. I've searched the web and the forums and they all either vaguely refer to the function call in Firefox or they imply that the onLoad, as I've got it written, works in IE and Firefox both. It doesn't.
Can anyone tell me how to do in Firefox what the above code does in IE? Please? e? Spriggan? Tage?
-
I've found that FireFox, due it's being so wrapped up in "strict" functionality, ends up missing a lot of stuff. onLoad is *supposed* to work, but that doesn't mean it will. I can't remember if Firefox has an error console. If so, you could use that to get an exact error, I might be able to work with it better.
-
Firefox does have a javacript console but it's not throwing an error. It just doesn't work.
How does one tell Firefox to run a javascript function only once everything is loaded? That's all I want to do really.
If you don't usually work with Firefox, and thus don't know how to do this off the top of your head, I wouldn't want you to spend time figuring it out. I would feel bad if you did.
-
It works in my FireFox.
<HTML>
<HEAD>
<SCRIPT>
function SetMenu(){
alert(1);
}
</SCRIPT>
</HEAD>
<body class="body" onLoad="SetMenu()">
Test
</body>
</HTML>
-
If you don't usually work with Firefox, and thus don't know how to do this off the top of your head, I wouldn't want you to spend time figuring it out. I would feel bad if you did.
I wouldn't feel bad about it. Most geeks who choose to go figure it out are doing it because they want to know themselves. They like doing that.
Unfortunately, I haven't really worked with JavaScript for a very long time, so I won't be much help, I think, aside from the obvious but often forgotten by everyone "check the options." You can turn JavaScript off in Firefox in the "web features" section. Make sure it's on. If it *is* enabled, you might want to click the "Advanced" button and see if any specific functions are turned off.
-
I wouldn't feel bad about it. Most geeks who choose to go figure it out are doing it because they want to know themselves. They like doing that.
I think e's got the situation pegged.
-
It's gotten more interesting now. I loaded up Eric's example code in a blank page and it worked in my Mozilla too. So it's not my browser settings.
But I still don't know why it doesn't work on MY pages. I found an inelegant and spotty workaround for this weeks ago and have been using that since so something in my page from long ago screws this up somehow. Thanks for the help, if you have any more thoughts let me know.
-
If you want to, email me the code (anything at ericjamesstone d0t c0m) or give a URL where the code is posted.
-
hrm... I seem to remember Firefox having trouble executing some JavaScript in a recent page I did. I think it was an HTML problem. Firefox being picky about that. email me the code (page and JavaScript) too and I'll look at it. I'm trying to remember what it was that fixed the problem.
-
Ah ha. I'm willing to bet now that the onLoad event in Firefox does not wait for the whole page to be loaded before it fires. Now I just have to figure out how to tell when the flash menu is done loading.
Sending you both the code now.
-
I'm not much of a JS man, though I have seen people place their <script> tags at the end of the page before the </html> to solve loading problems.
-
Would that help if the code was trying to talk to a .swf file? Or would the browser hit the script while still loading the .swf in the background?
-
OK, so I think you're right that it's executing before the swf file has loaded.
I'm afraid I don't know enough about JS interaction with Flash animations to be of help.
-
Thanks for looking at it anyway. I appreciate it.
The maddening thing is that all the forums are filled with workarounds so that you can fire events BEFORE the whole page is loaded. Everyone talks as though the onLoad event happens after all content, including images, is loaded and nobody but me wants it to happen the way it's suposed to. Arrrrrgh.
Some days my avatar feels more apropos than others.
-
FYI
I ended up having to bypass the whole problem by having the flash movie itself test whether it was all loaded and send a command to javascript to run the SetMenu function when it was.
Works.