views:

54

answers:

2

So I am trying to force every link on my blog to run a script, that show's the title in a css'able bubble rather than the standard yellow box, without having to insert the

onmouseover="tooltip.show('title value here');" onmouseout="tooltip.hide();"

in every <a> that it requires me to.

I really have no clue about Javascript or how to go about the problem. I googled a similar issue on this site but it didn't really solve anything for me.

This is what I got thus far;

<script>  window.onload = function () {
    window.document.getElementByAttr("title").onmouseover="tooltip.show("value");" onmouseout="tooltip.hide();"
    };
</script>

Site can be found at http://inane.se, it's the function on the search menu that I want to apply on every <a>

Any help would be highly appreciated~

Clarification: I am using Tumblr for the posting and thought it would be faster if I could do this automatically rather than going in to the html editor.

A: 

Replace

window.document.getElementByAttr

by

document.getElementsByTagName ( "a" )

which returns an array of elements with tagname "a" in your document.

Loop through the array and assign mouseover and mouseout.

rahul
+1  A: 

A suggestion:

Add regular title tags to as many "a" tags as necessary. Title is always a nice to have attribute; plus according to my understanding, you'll have to manually enter titles and/or JavaScript code to your "a" tags anyway.

Next: Google for jQuery tooltip plugin for anchor title tag and find one that attaches itself to "a" tags automatically.

Edit ----

OK, I'll be specific -- this is what you need:

document.getElementById('search').getElementsByTagName('input')[0].onmouseover = function(){alert('i am the textbox');}
document.getElementById('search').getElementsByTagName('input')[1].onmouseover = function(){alert('i am the submit button');}
document.getElementById('search').getElementsByTagName('a')[0].onmouseover = function(){alert('i am the 1st link that looks like a button');}
document.getElementById('search').getElementsByTagName('a')[1].onmouseover = function(){alert('i am the 2nd link that looks like a button');}
Salman A
jQuery is an advanced js library and one who has no clue about javascriptwil find it harder to use.
rahul
Yes probably right but you dont have to be a jQuery guru to use noob-ready plugins :)
Salman A