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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onLoad() method

Status
Not open for further replies.

tbone317

Technical User
Feb 22, 2001
3
US
The specification says that the onLoad() method is to be invoked in the <BODY> tag. Can I declare the onLoad within the JavaScript instead? The following is giving me an error.

function init()
{
var s = document.getElementsByTagName(&quot;A&quot;);
for(var i = 0; i < s.length; i++)
{
s.attachEvent(&quot;onclick&quot;, function(){if(this.hostname != document.location.hostname){var c = confirm('Are you sure you want to leave my site?');if(!c){return false;}}});
}
}
this.window.onLoad() = init;
 
this.window.onLoad=init;

read the faqs for this forum, there are some really good ones on events
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top