Jump to content

Recommended Posts

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;

Link to comment
https://forums.phpfreaks.com/topic/244804-onmouseover-null-opposite/
Share on other sites

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. :D Good luck!

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.

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>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.