473,805 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Display image when mouseover on anchor tag

129 New Member
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 10123
clain
79 New Member
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.h ref "

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 Recognized Expert Moderator Expert
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
5888
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 image not text. I have tried all sort of things like converting the columns image to tempate so on and still could display image
0
1479
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 enlighten me.... thanks a million~ Dim imgImage As WebControls.Image Dim lblLabel As Label
3
5249
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 database and display it in a Image web control dynamically(at runtime). The process after being displayed in the web control, user click insert/add button, it converts the image(jpeg) file to bytes and store it the database with Image or VarBinary...
3
19502
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 mouseover entire image, I want it on each hotspot only, so an image pertaining to each link shows up. I have done it in JavaScript, but the website I'm using doesn't use JavaScript. Y'all are obviously light-years more knowledgeable then me on html...
1
4664
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 column width or something.i would prefer doing it by mouseover.can anybody help me...my code is below <%@ Page Language="C#" AutoEventWireup="true" CodeFile="news_evnts.aspx.cs" Inherits="news_evnts" %> <!DOCTYPE html PUBLIC "-//W3C//DTD...
9
2850
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 any submit button. The image comes from a table where it needs to be retrieved from the selection criteria.
3
2167
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: HTML <div id="button1" class="alt" > <input type="image" name="GetStarted" class="alt-img10010" src="../Images/green.gif" style="border-width:0px;" /> </div>
3
13828
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 OUT* of image back to slightly transparent. this is what I have, it include the transparency of image, the mouseover/mouseout, the only thing missing is the FADE IN/FADE OUT, in other words SLOW DOWN/ADD A TIME SEGMENT TO WHICH THE TRANSPARENCY...
0
9718
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10613
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10368
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3846
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.