Forum Moderators: open

Message Too Old, No Replies

tooltip and firefox

         

akhater

12:11 am on Oct 17, 2006 (gmt 0)

10+ Year Member



I am trying to build a firefox extension that would change the tooltips of any image in a webpage to the value of the SRC can anyone point me in the right direction please

thanks

Fotiman

3:22 pm on Oct 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



By tooltip, do you mean the title attribute? Here, this will do it.



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset:utf-8">
<title>Dynamic Src Titles</title>
<script type="text/javascript">
function createImageTooltips()
{
var imgList = document.getElementsByTagName('img');
for( var i = 0; i < imgList.length; i++ )
{
// See if there's src we can use for title
var src = imgList[i].getAttribute("src");
if( src )
{
// Use src text to modify title
imgList[i].setAttribute("title",src);
}
}
}
function attachBehaviors()
{
// Create image tooltips
createImageTooltips();
}
window.onload = attachBehaviors;
</script>
</head>
<body>
<img src="foo.gif">
<img src="xyz.gif">
<img src="bar.gif">
</body>
</html>

[edited by: Fotiman at 3:22 pm (utc) on Oct. 17, 2006]

akhater

7:13 pm on Oct 17, 2006 (gmt 0)

10+ Year Member



Fotiman thanks
yes i was talking about the title, I will test it, hope it will work on firefox too.

thanks a million

Fotiman

8:08 pm on Oct 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




hope it will work on firefox too.

But of course! Always better to write for Firefox first, and THEN test it in IE. :-)