Click to See Complete Forum and Search --> : Remote onMouseOver
PhilgB
05-16-2003, 08:20 AM
I wrote a function in a .js file that detects 'onmouseover's then changes the statusbar accordingly.
document.onMouseOver = chkMnuMovr;
function chkMnuMovr() {
var tmpEl = event.srcElement;
if (tmpEl.tagName == "A") {
window.status = tmpEl.innerHTML; return true;
}
}
This works fine in IE but not in any others. Any ideas?
Thanks
srcElement is IE only. http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/properties/srcelement.asp
khalidali63
05-16-2003, 08:39 AM
That is because you are using MS specific code in it,to make your code work for NS as well you need to capture events
the following will work for both NS and IE
function chkMnuMovr(e) {
var tmpEl = (e)? e.target : event.srcElement;
if (tmpEl.nodeName == "A") {
window.status = tmpEl.innerHTML;
return false;
}
}
if(!document.all){
document.captureEvents(Event.MOUSEOVER);
}
document.onmouseover = chkMnuMovr;
PhilgB
05-16-2003, 10:47 AM
Thanks!
PhilgB
05-16-2003, 02:36 PM
Actually, this is what Im using now, and it works with IE,MOZ,OPERA, but not netscape, did i miss something?
if (!document.all) {document.captureEvents(Event.MOUSEOVER);}
if (!document.all) {document.captureEvents(Event.MOUSEOUT);}
document.onmouseover = chkMnuMovr;
document.onmouseout = chkMnuMovr;
function chkMnuMovr(e) {
var tmpEl = (e) ? e.target : event.srcElement;
if (tmpEl.nodeName == "A") {
if (window.status == tmpEl.title) {window.status = "sometext";}
else {window.status = tmpEl.title}
return true;
}
}
PhilgB
05-17-2003, 06:52 PM
achoo............
AdamBrill
05-17-2003, 07:14 PM
Bless you. :D Anyway, try this code(tested in IE6 and NS7):<html>
<head>
<title>Untitled</title>
<script language="JavaScript" type="text/javascript">
function run_onload(){
if (!document.all) {document.captureEvents(Event.MOUSEOVER);}
if (!document.all) {document.captureEvents(Event.MOUSEOUT);}
document.onmouseover = chkMnuMovr;
document.onmouseout = chkMnuMovr;
}
function chkMnuMovr(e) {
var tmpEl = (e) ? e.target.parentNode : event.srcElement;
if (tmpEl.nodeName == "A") {
if (window.status == tmpEl.title) {window.status = "sometext";}
else {window.status = tmpEl.title}
return true;
}
}
</script>
</head>
<body onload="run_onload()">
<a href="test.htm" title="This is a test!">test</a>
</body>
</html>
PhilgB
05-18-2003, 11:26 AM
yeah... it half works with NS7 and doesnt work at all with NS6.
When I pass my mouse over the padding of a link, the window status changes then once the cursor is over the text of the link, it changes to whatever is in the href of that link. In NS6 the status doesnt show the title, it just shows the href of the link.
thanks