MDanz Posted August 15, 2011 Share Posted August 15, 2011 onmouseover = null disables onmousever.. How do i renable it again? I tried not null but it didn't enable onmouseover. I didn't include the functions btw. document.getElementById('row'+number).onmouseover =null; document.getElementById('row'+number).onmouseover !=null; When i try disabled=true or false it doesn't disable onmouseover, so the below didn't work. document.getElementById('row'+number).onmouseover.disabled =true; document.getElementById('row'+number).onmouseover.disabled =false; Quote Link to comment https://forums.phpfreaks.com/topic/244804-onmouseover-null-opposite/ Share on other sites More sharing options...
JasonLewis Posted August 15, 2011 Share Posted August 15, 2011 Hm, perhaps try storing the onmouseover object before setting it to null? Then setting it back again. var omo = document.getElementById('row'+number).onmouseover; document.getElementById('row'+number).onmouseover = null; // Later, you can reset it. Maybe. document.getElementById('row'+number).onmouseover = omo; No idea if this would work or not. In theory it sounds alright, at least to me it does. Good luck! Quote Link to comment https://forums.phpfreaks.com/topic/244804-onmouseover-null-opposite/#findComment-1257538 Share on other sites More sharing options...
Adam Posted August 15, 2011 Share Posted August 15, 2011 I don't think you should disable the mouseover event, but add a condition within the handler code to carry out the action or not. At the moment you're unbinding the event when you set it to null, so to re-bind it you would need to literally define the event again. As I said though, this makes less sense than just having a condition within the event handler. Quote Link to comment https://forums.phpfreaks.com/topic/244804-onmouseover-null-opposite/#findComment-1257630 Share on other sites More sharing options...
MDanz Posted August 15, 2011 Author Share Posted August 15, 2011 ok i added a condition but it still doesn't work. Can you help me correct the code below? You can just copy and paste and try it yourself. onmouseover the red boxes appear. If i click(X) the red box should close but it doesn't. Only doubleclicking (X) closes the red box. Onmouseover it should always display the red box though. <html xmlns="http://www.w3.org/1999/xhtml"> <head> </head> <style type="text/css"> .container { display:block; width:500px; height:200px; border:1px solid green; } .advert { float:right; overflow:hidden; width:100px; height:30px; border:1px solid red; } .close { float:right; width:20px; height:28px; cursor:pointer; border:1px solid black; } </style> <body> <div class="container" onmouseover='getad(39);' onmouseout='hidead(39);changeback(39);'> <div class='advert' id="39" style="display:none;"><div class="close"><a href="javascript:closead(39)">X</a></div></div> <input type="text" value="1" id="ad39" /> </div> <div class="container" onmouseover='getad(40);' onmouseout='hidead(40);changeback(40);'> <div class='advert' id="40" style="display:none;"><div class="close"><a href="javascript:closead(40)">X</a></div></div> <input type="text" value="1" id="ad40" /> </div> <script type="text/javascript"> function getad(number) { if(document.getElementById('ad'+number).value==1) { if(document.getElementById(number).style.display == "none") { document.getElementById(number).style.display = "block"; } } } function hidead(number) { if(document.getElementById('ad'+number).value==1) { if(document.getElementById(number).style.display == "block") { document.getElementById(number).style.display = "none"; } } } function closead(number) { document.getElementById('ad'+number).value = 0; if(document.getElementById(number).style.display == "block") { document.getElementById(number).style.display = "none"; } } function changeback(number) { if(document.getElementById('ad'+number).value==0) { document.getElementById('ad'+number).value = 1; } } </script> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/244804-onmouseover-null-opposite/#findComment-1257771 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.