Select Categories Below
Quomon shares its advertising revenue with contributing experts that answer questions effectively. Join our community to share your knowledge and earn an income as you go.
Status: Closed Points: 50 Time: 19:35 - Oct 12, 2006
jgivoni
Consider this code: <html> <head> <title>test</title> <script src="test.js" onload="alert('ok')"></script> </head> <body> </body> </html> We must presume that test.js exists of course. According to MSDN the ONLOAD event should fire when the browser has loaded the object: http://msdn.microsoft.com/workshop/autho... (Notice the "Applies to: Script") But it doesn't fire. At least not in my IE 6 browser. (In FF 1.5 it does) Anybody knows why? Or get different results?
Categories:
Add Categories
When adding more than one category, separate them with commas.
Advertisement
Anpanman
Date:: Oct 13, 2006
Time:: 00:18
I didn't know this should be possible, but couldn't you use the <body onload="javascript: alert('ok');"> instead?
Time:: 14:45
I could, except that my html files are generated by php and the body part comes from one file, the scripts included on a given page from another. Therefore I would prefer that the loading of a given script incur the execution of that script. Actually the event would be: onload="init()". Now you could say that why don't I just include that line "init();" as the first one in the actual script? Beacuse maybe I want to include the script without executing the init() in some cases. Don't worry, there are plenty of other solutions, I just would like to know if anyone had knowledge about this specific issue. I'll keep the question open...
nhinds
Date:: Nov 01, 2006
Time:: 00:35
I would stay away from tags like that, and use something like this: if (window.addEventListener) window.addEventListener('load',init,false); else if (document.addEventListener) document.addEventListener('load',init,false); else if (window.attachEvent) window.attachEvent('onload',init); else {//Older browsers only if (typeof window.onload=='function') { var oldload=window.onload; window.onload=function(){ oldload(); init(); } } else window.onload=init; }
Date:: Nov 06, 2006
Time:: 02:04
nhinds, why would you stay away from tags like that? And another thing; at what point and how do you suggest to run the script you propose?
Time:: 21:44
I avoid tags like onload because, in my opinion, they just pollute the markup (although that can be taken too far). Just throw that code in at the end of the javascript file you're including, or in its own script tag below the script with init in it
Date:: Nov 21, 2006
Time:: 12:32
But nhinds, if I put it in a script tag below the one that loads the script - wouldn't that just pollute the markup even more? And if I put it inside the script itself, then I know that the script is already loaded, and I no longer need to attach any onload event to it! Finally, my original question still stands uncommented: Why doesn't the even fire - even though the documentation provided by the manufacturer states that it should? I can see three posibilities so far: 1) I am reading the documentation wrong 2) I am reading the wrong documentation 3) It is a bug (may be limited to certain versions)
haris
Date:: Aug 20, 2007
It occurs in specific conditions which are unspecific. I create a simple HTML page and add an alert in body onload, it gives the alert but when I do the same in my ASP.NET application page (it has a lot of code) it does not work. May be some other javascript call falsifies it. Occurs only in IE 6.0. FF, Opera work well. If you find any solution, please post it to www.burqe.com contact us so it may reach me and I need it.
uiqzfarkrypq
Date:: Nov 24, 2008
Time:: 12:48
Here is one solution: http://somanyschemes.com/2008/11/23/repl...
Question Answered
This question has been closed, and points have been rewarded to the following experts:
You're welcome however to comment or give additional information or if you wish, you have the ability to write a Tutorial in the Tutorial Area.
Answer this Question
New User
Email:
Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address
Registered User
Username:
Password:
Forgot Your Password?
Enter your email address below and we will resend your login information to you.
Login Information Sent
Questions
I would like to connect my wireless laptop to a printer which is connected to...
Microsoft OLE DB Provider for SQL Server error '80040e10'
Binding a dropdownlsit to a button to determine datagrid rows
Problem in the bluetooth of my Laptop
"windows needs to install bluetooth peripheral device" appears,although its i...
How do I trigger an event which was set up with dojo.connect?
You have 100 characters to use
Rank
Expert
Points
1.
1355
2.
735
3.
414
4.
272
5.
250
6.
125
7.
100
8.
75
9.
65
10.
50
Register today to share your knowledge with the community and be recognized and rewarded for your contributions.
Register Here
"Psst, Quomon is a great site. Pass it on." Tell a Friend | Link To Us | Save to Delicious | Digg it
Language Options
English:
Español:
Sponsors
Questions and Answers Software Real Estate Postcards Marketing Fulfillment