By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,849 Members | 2,169 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,849 IT Pros & Developers. It's quick & easy.

My script is neutralized

manuelgk
P: 54
Hello everybody, yesterday I have troubles with my js. It executes very well in pages that don't have a "window.onload" function, even if they have another script but, if the Web page contain a js call like this, my script simply doesn't work. I read in the Web that if I have another script with the same function ("window.onload"), they colapse because there are 2 functions with the same name. My question is: is there anyway to put toghether 2 or more "window.onload" even if this one is in a link or another script? what can I do to modify my script against those things?
Thanks
Feb 1 '08 #1
Share this Question
Share on Google+
2 Replies


100+
P: 428
put this in your script, in place of your onload assignment:

Expand|Select|Wrap|Line Numbers
  1. if(window.addEventListener){
  2. window.addEvent('load',functiontorunonload,false);
  3. }
  4. else if(window.attachEvent){
  5. window.attachEvent('onload',functiontorunonload);
  6. }
If the other onload scripts conflict with your script's methods or properties,
things won't work out. And if the page has loaded before your script, the onload won't fire again for you.
Feb 1 '08 #2

manuelgk
P: 54
put this in your script, in place of your onload assignment:

Expand|Select|Wrap|Line Numbers
  1. if(window.addEventListener){
  2. window.addEvent('load',functiontorunonload,false);
  3. }
  4. else if(window.attachEvent){
  5. window.attachEvent('onload',functiontorunonload);
  6. }
If the other onload scripts conflict with your script's methods or properties,
things won't work out. And if the page has loaded before your script, the onload won't fire again for you.
Thanks for the answer, I keep it in mind
Feb 7 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.