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

IE7 window.attachEvent onclick doesn't work 2

Status
Not open for further replies.

TallOne

Programmer
May 14, 2004
164
US
Can someone help me with creating a onclick event for IE window? Onload works but not onclick?

I'm using this in an ASP.NET page
Code:
<script type="text/javascript"src="theCodeBelow.js"></script>

Code:
(function() {
window.attachEvent("onload", function(event)
{    
    alert('onload occured');
}, false);

 
window.attachevent("onclick", function(event)
{
    alert('you clicked me');
}, false);

})();
 
Sorry, that was a typo. I still have the same issue.
 
Sorry this is an intranet. Place this in an html file and you should be able to reproduce....
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <script>
  (function() {
    window.attachEvent("onload", function(event)
    {    
        alert('onload occured');
    }, false);
    
    window.attachevent("onclick", function(event)
    {
        alert('you clicked me');
    }, false);
    
    })();

  </script>
  </head>
  <body>
    MyBody
  </body>
</html>
 
Again without the typo....

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <script>
  (function() {
    window.attachEvent("onload", function(event)
    {    
        alert('onload occured');
    }, false);
    
    window.attachEvent("onclick", function(event)
    {
        alert('you clicked me');
    }, false);
    
    })();

  </script>
  </head>
  <body>
    MyBody
  </body>
</html>
 
The typo got propagated.
[tt] window.[red]document.[/red]attach[red]E[/red]vent("onclick", function(event)
{
alert('you clicked me');
}, false); [/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top