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:
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.Code:<div id="clickme" onclick="document.onclick = function(){ alert ('This should not be alerted on the first click'); }">Click here</div>


Reply With Quote
Bookmarks