title = status ? - part 2

N

NielsM

Hello All,

Found a bit of Javascript on this forum that shows the title-text of a
link in the statusbar, so you don't have to type
onmouseover="window.status='bla di bla'" in every link.

http://groups.google.nl/group/comp....read/thread/16906e69836826c3/4922a5c1a40fd2a1

But it does not show the title when the link (<a href=""..>text</a>)
is in a DIV tag.
Can someone help me so all links on my page have a statusbar text on
mouse over no matter how deep they are nested.

Some example code:
<html>
<head>
<title>Test javascript title</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script>
function setMEvents() {
var oDocBodyNodes = document.body.childNodes;
for (var i = 0; i < oDocBodyNodes.length; i++) {
if (oDocBodyNodes.nodeType == 1 && typeof
oDocBodyNodes.title != 'undefined') {
oDocBodyNodes.onmouseover = function() { window.status
= this.title; return true; }
oDocBodyNodes.onmouseout = function() { window.status =
''; return true; }
}
}
}
</script>
</head>
<body onload="setMEvents()">
<div id="test">this link is inside a DIV tag <a href="#" title="does
not work">and therefore does not work</a></div>
<a href="#" title="This works">This is a normal link which shows the
title in the statusbar on mouse over</a>
<div id="level0"> <a href="#" title="link in div">link level 0 - link
in div</a><br>
<div id="level1"> <a href="#" title="link in div in div">link level
1 - link in div in div</a></div>
</div>
</body>
</html>

Thanks,
Niels

PS: This only works in Internet Explorer since FireFox does not
support the statusbar text option.
PS 2: I do not want to go into a discussion about the use (or mis-use)
of the statusbar and it's intentional purpose. It all about optimizing
my code to get a smaller page size
 
T

Tom Cole

Hello All,

Found a bit of Javascript on this forum that shows the title-text of a
link in the statusbar, so you don't have to type
onmouseover="window.status='bla di bla'" in every link.

http://groups.google.nl/group/comp.lang.javascript/browse_thread/thre...

But it does not show the title when the link (<a href=""..>text</a>)
is in a DIV tag.
Can someone help me so all links on my page have a statusbar text on
mouse over no matter how deep they are nested.

Some example code:
<html>
<head>
<title>Test javascript title</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script>
function setMEvents() {
var oDocBodyNodes = document.body.childNodes;
for (var i = 0; i < oDocBodyNodes.length; i++) {
if (oDocBodyNodes.nodeType == 1 && typeof
oDocBodyNodes.title != 'undefined') {
oDocBodyNodes.onmouseover = function() { window.status
= this.title; return true; }
oDocBodyNodes.onmouseout = function() { window.status =
''; return true; }
}
}}

</script>
</head>
<body onload="setMEvents()">
<div id="test">this link is inside a DIV tag <a href="#" title="does
not work">and therefore does not work</a></div>
<a href="#" title="This works">This is a normal link which shows the
title in the statusbar on mouse over</a>
<div id="level0"> <a href="#" title="link in div">link level 0 - link
in div</a><br>
<div id="level1"> <a href="#" title="link in div in div">link level
1 - link in div in div</a></div>
</div>
</body>
</html>

Thanks,
Niels

PS: This only works in Internet Explorer since FireFox does not
support the statusbar text option.
PS 2: I do not want to go into a discussion about the use (or mis-use)
of the statusbar and it's intentional purpose. It all about optimizing
my code to get a smaller page size


This seemed pretty easy:

function setMEvents() {
for (var i = 0; i < document.getElementsByTagName("a").length; i++) {
var node = document.getElementsByTagName("a");
if (node.title) {
node.onmouseover = function () { window.status = this.title; return
true; }
node.onmouseout = function () { window.status = ''; return true; }
}
}
}
 
N

NielsM

Wow it works, THANKS a lot !!

This may seemed easy for you... I have no programming skills and
fooled around with the 'ChildNodes' to get it working with no results
of course ;-) Looks like the getElementsByTagName does the trick.

Thanks again Tom.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top