I have an overlay that appears on a different part of the page. I want it to show the anchor title for each link they mouseover. I've coded much of it, just don't know how to pass the title to the overlay. Clues?
document.getElementById("overlay").innerHTML = this.title; Code (markup): ??? I'm not sure exactly what you mean.. posting the code that you have would help a lot.
When someone mouses over a link... <a href="" onmouseover="overlay" title="example"> Code (markup): ... an over lay will appear on another part of the site with the title used on the link. <div id="overlay">example</div> Code (markup): How can I do this?
try with jquery: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('a').hover(function() { $('#overlay').html($(this).attr('title')); }, function () { $('#overlay').html(''); }); }); </script> Code (markup):
I hear it works ok with IE, but I'm on a Mac and using Firefox, which has a problem. With Firefox, the overlay jumps and wont stay visible. Thoughts?
replace function show(string) { elidoverlay = document.getElementById("overlay"); document.getElementById("overlaymsg").innerHTML = string; elidoverlay.style.visibility = "visible"; } function hide() { elidoverlay = document.getElementById("overlay"); elidoverlay.style.visibility = "hidden"; } Code (markup): with $(document).ready(function(){ $('#overlay').hide(); $('area').hover(function() { $('#overlay').show(); $('#overlaymsg').html($(this).attr('title')); }, function () { $('#overlay').hide(); $('#overlaymsg').html(''); }); }); Code (markup): remove visibility:hidden in your overlay css style remove onmouseover="show('Free Internet TV')" onmouseout="hide()" and that worked when I tried with firefox
You don't want to add inline JS to every single link. Try this (uncomment the div overlay and remove the img overlay). <div id="overlay"><div id="overlaymsg">link title</div></div> </center> <script type="text/javascript"> var as = document.getElementsByTagName("area"); var ol = document.getElementById("overlay"); for(i=0;i<as.length;i++) { as[i].onmouseover = function() { ol.childNodes[0].innerHTML = this.getAttribute("title"); ol.style.visibility = "visible"; } as[i].onmouseout = function() { ol.childNodes[0].innerHTML = ""; ol.style.visibility = "hidden"; } } </script> </body> Code (markup): There is no need for jQuery...
I figured it out so it works with all browsers, including the clicking. Now I just need to position is correctly on the page.
I used to have this code.. well it is jut for an article post.. <a href="website" title"">KW</a> haha.. iam just trying to help.. hope i made sense.