Current location: Hot Scripts Forums » General Web Coding » JavaScript » onmouseover not working in ie


onmouseover not working in ie

Reply
  #1 (permalink)  
Old 11-10-09, 11:58 PM
kshatriy kshatriy is offline
New Member
 
Join Date: Nov 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
onmouseover not working in ie

Hello pals,

HTML code:
HTML Code:
<dt><a href="#" onmouseover="addButton(this);" onmouseout="removeButton(this);">CNN News<img src="http://www.hotscripts.com/forums/images/cnn.gif" alt="cnn" style="width:67px; height:43px;"/></a></dt>
Javascript:
HTML Code:
function addButton(selected){ 
    var add = "CNN News<img src=\"http://www.hotscripts.com/forums/images/cnn.gif\" alt=\"cnn\" style=\"width:67px; height:43px;\"/><img id=\"add\" src=\"http://www.hotscripts.com/forums/images/add.gif\" alt=\"Add\" />";
    selected.innerHTML = add;
}

function removeButton(selected){ 
    var add = "CNN News<img src=\"http://www.hotscripts.com/forums/images/cnn.gif\" alt=\"cnn\" style=\"width:67px; height:43px;\"/>";
    selected.innerHTML = add;
}
Here my problem is:
when the mouse moved over image its not calling the addButton() but when mouse is outside of the image and on <a> element its calling the addButton() func.

<img> is a child of <a> element and its working fine in FF....

Any clues... Thanks in advance...

Last edited by job0107; 11-11-09 at 01:13 PM.
Reply With Quote
  #2 (permalink)  
Old 11-11-09, 01:12 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
IE doesn't render innerHTML the same way as other browsers.
That is why you are having problems with your code.
Instead, define the 'add' image in the body and use javascript to toggle the display property.
Example:
HTML Code:
<html>
<head>
<script>
function add_remove_Button(selected,type){
 if(type){document.getElementById(selected).style.display = "inline";}
 else{document.getElementById(selected).style.display = "none";}
}
</script>
</head>
<body>
<dt><a href="#" onmouseover="add_remove_Button('add',1);" onmouseout="add_remove_Button('add',0);">CNN News<img src="http://www.hotscripts.com/forums/images/cnn.gif" alt="cnn" style="width:67px; height:43px;" /><img id="add" src="http://www.hotscripts.com/forums/images/add.gif" alt="Add" style="display:none;" /></a></dt>
</body>
</html>
__________________
Jerry Broughton

Last edited by job0107; 11-11-09 at 01:30 PM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OnMouseOver problem RevWaters PHP 4 04-13-09 07:10 AM
[SOLVED] Make Rewrite Modul Working in Windows, cause .htaccess ist not working specialex Web Servers 5 04-09-08 11:07 AM
footer working in some browsers but not all pkcidstudio CSS 6 08-25-06 08:39 AM
HTTP_REFERER not working Kaikki ASP 6 02-22-04 02:38 PM


All times are GMT -5. The time now is 01:58 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.