Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / February 2007



Tip: Looking for answers? Try searching our database.

title = status ? - part 2

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
NielsM - 28 Feb 2007 16:48 GMT
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/thread/16906e69
836826c3/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[i].nodeType == 1 && typeof
oDocBodyNodes[i].title != 'undefined') {
           oDocBodyNodes[i].onmouseover = function() { window.status
= this.title; return true; }
           oDocBodyNodes[i].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
Tom Cole - 28 Feb 2007 21:53 GMT
> Hello All,
>
[quoted text clipped - 51 lines]
> 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")[i];
        if (node.title) {
            node.onmouseover = function () { window.status = this.title; return
true; }
            node.onmouseout = function () { window.status = ''; return true; }
        }
    }
}
NielsM - 28 Feb 2007 22:12 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.