www.webdeveloper.com
Results 1 to 2 of 2

Thread: How do I make an onclick event change the document.onclick ?

  1. #1
    Join Date
    Sep 2010
    Posts
    1

    How do I make an onclick event change the document.onclick ?

    Exactly what the title says? I want to make it so that when I click on something, it changes what document.onclick does.

    This is a simplified version of what I'm trying to do:

    Code:
    <div id="clickme" onclick="document.onclick = function(){ alert ('This should not be alerted on the first click'); }">Click here</div>
    However, as you'll notice, the alert box shows up on the first click as well. The only way I have been able to get around this behaviour is to have the first onclick execute a timer that will then set the document.onclick after 1ms, however this seems very messy to me.

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    <div id="clickme" onclick="document.onclick = function(){if(typeof counter == 'undefined')counter=0; else alert ('This should not be alerted on the first click'); }">Click here</div>
    At least 98% of internet users' DNA is identical to that of chimpanzees

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles