473,405 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Display image when mouseover on anchor tag

129 100+
Hello friends,
I know that an image can used as link. But what my doubt is, when mouse moves on a link it should display an image corresponding to that link, and in tha place of link only.

That means, for example we have few cinema directors names on a page, every name is a link, and when i move mouse on that link the photo of that director should display there.

Can any one please help me with code in html or javascript.
Dec 16 '08 #1
2 10107
clain
79
you can create div's which have the names links ... let id of each links be the same name as the link..

now onMouseover event of div should call a function which passes the div id as parameter.. this function should hide the link in that div and should display the image...

now onMouseout function should call a function which passes the id ...which hides the image and shows the link..

make sure that your image have a link which redirects to actual link page...

use "location.href "

enjoy coding..!!!!!

I hope you got it.....!!!

by the way Administrators ..please move this to JavaScript forums.

Thank you
Dec 16 '08 #2
Dormilich
8,658 Expert Mod 8TB
whether you have to code in html or javascript depends on your html.

examples (sketches)
Expand|Select|Wrap|Line Numbers
  1. // html:
  2. <div class="sioh">
  3.   <a href="…">John Doe</a>
  4.   <img src="jdoe.png" … >
  5. </div>
  6. // css:
  7. .sioh img {
  8.   visibility: hidden;
  9. }
  10.  
  11. .sioh:hover img {
  12.   visibility: visible;
  13. }
Expand|Select|Wrap|Line Numbers
  1. // html
  2. <a class="ioh" id="jdoe" href="…">John Doe</a>
  3. // js
  4. var links = getElementsByClassName('ioh'); // function by Robert Nyman
  5. var l = links.length;
  6. for (var i=0, i<l; i++)
  7. {
  8.   addEvent(links[i], "mouseover", showImg); // there are many addEvent() versions around (→ google)
  9. }
  10. function showImg()
  11. {
  12.   // ImgInfoObj holds the attribute values of every image
  13.   // select apropriate infos
  14.   var desc = ImgInfoObj[this.id];
  15.   // create an image node using DOM
  16.   // function to be defined elsewhere
  17.   var img = createImg(desc.src, desc.width, desc.height, desc.alt);
  18.   // insert img to the page
  19.   // use this.firstChild.replaceChild() if you want to replace the text
  20.   this.appendChild(img); 
  21. }
@clain
not if the problem should be solved by CSS...
@clain
that depends on the actual code.

regards
Dec 16 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tan | last post by:
Hi I am desperate for any help with display image in Gridview I have a gridview contain surname , forename ..... and image. I could not display image as my database store the column image as...
0
by: Panic Student | last post by:
hi all, i'm having trouble with changing image when mouseover on a particular label. Below is what i attempted to but it didn't seem to work at all. I guess my concept is wrong ): Please...
3
by: den 2005 | last post by:
Hi everyone, Here is code working on..Trying to insert record with a column with Image or VarBinary datatype in sql database from a existing jpeg image file, then retrieve this image from...
3
by: Annette Acquaire | last post by:
I have and image map with a dozen hotspot links on it that I'm trying to get to open a new image over existing one on mouseover of each COORD. The only thing I was able to do was swap image on...
1
by: lisles | last post by:
hi; Im using a gridview to display images in 1 of the column...but the size of the images is very small.is there anyway to enlarge the image on mouseover or even without mouseover by adjusting the...
9
by: chabbs | last post by:
Hi, I have my form with some combo box and radio button. And i need to display an image based on the selections. I need to display dynamically the image when the selections are made without...
3
by: tess1243 | last post by:
I want the image to be changed when it is hovered, and display the changed image on the hovered image. I want the changed image exactly to display on the hovered image. Here is the code: ...
3
by: Torie Photgraph | last post by:
I am wondering if there is a css code that would enable a fade in/fade out image mouseover transparency? picture this: image is slightly transparent, mouseover: *FADE INTO* image mouseout: *FADE...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.