JavaScript - Mouse Roll Overs
I want to mouse over a symbol (or coordinate) on an image and have a photograph appear of the real life item. Is there a code that could be used for doing this?
Any help appreciated. Similar TutorialsCould some one help me with achieving a roll over effect? Not the type where you hover over a link and a image appears and then you move away from the link and it disappears but rather like the ones viewable in the roll over section here @ www.dailyscience.com - that is you hover over a link and text and an image appears but then you move away and it still remains until you hover over another link? I'm a novice to javascript and am still learning so any help would really be appreciated, thanks! PS I realise there is a connection to the HTML code as this is where the content lies but interlinking this with my desired effect is rather annoying. Once again thanks. Hi. I'm trying to make a progression module for my guild. I would like it to be "lightbox" with several thumbnail images one can over over to bring up some descriptive text. How can I do this? I assume it's simple code. Thank you very much. I've got to have a typo somewhere, but i can't seem to find it. I need a new pair of eyes to point it out for me. background: trying to code a mouseover link for a nav bar. everything is working( hyperlink, normal image shows up) but when i mouse over the image swap doesn't happen. I have 2 parts of code. 1st preloads images and does the swap function. loads in <head> See below: Code: <SCRIPT language="javascript" type="text/javascript"> if (document.images) { /* preload images */ var subcontractorsOn = new Image (); subcontractorsOn.scr = "subcontractorsOn.gif"; var subcontractorsOff = new Image (); subcontractorsOff.scr = "subcontractorsOff.gif"; } function mouseOn (imgName) { if (document.images) document [imgName].scr = eval (imgName + "On.scr"); } function mouseOff (imgName) { if (document.images) document [imgName].scr = eval (imgName + "Off.scr"); } </SCRIPT> 2nd just calls the functions to preform the swap. this is in the <body> see code below Code: <a href="subcontractors.htm" onMouseOut="mouseOn('subcontractors')" onMouseOver="mouseOff('subcontractors')"> <img src="subcontractorsOff.gif" height="40" width="133" name="subcontractors" id="subcontractors" border="0" alt="subcontractors"></a> any insight would be great. regards, Fatmann66 Hi all, I was just wondering if there is a JavaScript tutorial online that shows you how to do similar hover effect to what Twitter does with the trending topics. Such as Inception. When you hover over it and a black bubble appears. Also I'm not sure what it is called. If anyone knows how to do it, It would be appreciated. Thanks! Hi friends, Im new with JS. How to make the roll over effect in JS. An image, on roll over, the big size of the same image needs to appear. regards anoop I am trying to create a multiple image rollover and when you click on an image, the page will direct to a relevant external website. However only the first image changes when you rollover it, the other four images will not change. Any suggestions?? Code: <HTML><HEAD><TITLE>Monsters Inc Rollover Images</TITLE> <META content="text/html; charset=iso-8859-1" http-equiv=Content-Type> <SCRIPT language=Javascript type=text/javascript> <!-- var monstersincON = new Image; var sulley = new Image; var mike = new Image; var booON = new Image; var randallON = new Image; var monstersincOFF = new Image; var sulleyOFF = new Image; var mikeOFF = new Image; var booOFF = new Image; var randallOFF = new Image; monstersincON.src = "../images/monstersinc.jpg"; sulleyON.src = "../images/scully.jpg"; mikeON.src = "../images/mike.jpg"; booON.src = "../images/boo.jpg"; randallON.src = "../images/randall.jpg"; monstersincOFF.src = "../images/monstersincoff.jpg"; sulleyOFF.src = "../images/scullyoff.jpg"; mikeOFF.src = "../images/mikeoff.jpg"; booOFF.src = "../images/boooff.jpg"; randallOFF.src = "../images/randalloff.jpg"; /* Callout: This function takes two parameters, the version name (ON or OFF) and the image name. This makes it possible to handle all image swapping with only this one function. */ function swapImage(version, imagename){ if (document.images){ document[imagename].src = eval(imagename + version + ".src"); } } /* Callout: This function turns all images back to their 'off' versions. */ function rollOffAll(){ swapImage('OFF','monstersinc'); swapImage('OFF','sulley'); swapImage('OFF','mike'); swapImage('OFF','boo'); swapImage('OFF','randall'); } //--> </SCRIPT> </HEAD> <BODY bgColor=white> <DIV align=center><A onmouseover="swapImage('ON','monstersinc');" onmouseout=rollOffAll(); onclick="rollOffAll();return true;" href="http://.html"><IMG border=0 name=monstersinc alt="Monsters Inc" src="../images/monstersincoff.jpg" width=250 height=250></A> <HR> <BR><A onmouseover="swapImage('ON','sulley');" onmouseout=rollOffAll(); onclick="rollOffAll();return true;" href="http://www..html"><IMG border=0 name=sulley alt=Sulley src="../images/sulleyoff.jpg" width=175 height=225></A> <BR><A onmouseover="swapImage('ON','mike');" onmouseout=rollOffAll(); onclick="rollOffAll();return true;" href="http://www..html"><IMG border=0 name=mike alt=Mike src="../images/mikeoff.jpg" width=175 height=225></A> <BR><A onmouseover="swapImage('ON','boo');" onmouseout=rollOffAll(); onclick="rollOffAll();return true;" href="http://www..html"><IMG border=0 name=boo alt=Boo src="../images/boooff.jpg" width=175 height=225></A><BR> <BR><A onmouseover="swapImage('ON','randall');" onmouseout=rollOffAll(); onclick="rollOffAll();return true;" href="http://www..html"><IMG border=0 name=randall alt=Randall src="../images/randalloff.jpg" width=175 height=225></A><BR> </DIV> </BODY> </HTML> Hello. I want to display some text in some part of website when user "rolls over" an image. How can I make it possible? Text position must be totally flexible. (not over image) Hi there, If anyone can help me it would be incredibly appreciated. I have this JavaScript file below. Currently it roll's over the image fine but the image stays as the hover after the mouse rolls over. Is there a really quick way to add a roll off/ mouse off function so the image rolls back to the underlying image? Again thank you in advance for any help you can provide for this problem as I'm very new to JavaScript! Chris *********** "// JavaScript Document $(function() { $('img[data-hover]').hover(function() { $(this).attr('tmp', $(this).attr('src')).attr('src', $(this).attr('data-hover')).attr('data-hover', $(this).attr('tmp')).removeAttr('tmp'); }).each(function() { $('<img />').attr('src', $(this).attr('data-hover')); });; }); *********** How can I make a image where the first image "rolls" up and another (different) image "rolls" up from the bottom? I know how to code it except for the animation sequence. All images are 200 width and 50 height.\ Thanks in advance! (Would like to use jQuery if possible) Can anyone show me the code for a simple expanding navigation bar? I need to roll over the nav bar and for it to drop down with more options. I know the code will be straight forward, I can't work it out though. Thanks whoever can help = ) Hi, I've investigated contacting the author, but it doesn't look like I'll get a swift response. The script I'm using is hosted here The script is designed to create a fullscreen, scaling background that can be used as a carousel gallery for images, with a caption that floats next to the mouse pointer that either reads 'next' or 'previous'. It works fine but I am attempting to alter the script to do a few things: 1.Make the image take up a proportionate amount of window space - 85% (done) 2.Get rid of the text which appears on rollover(done) 3.Assign an image flip for the proportionally scaled image (this is the one I'm having problems with) I'm trying not to include too much information but it's hard to know where the problem is. I'm fairly sure this is used to set the scaler up on the page: Code: (function(){ var bg=document.getElementById('bg'),float=document.createElement('span'),scale=Scaler(bg); //Create and bind scaler-function addEvent=function(el,on,fn){el.attachEvent?el.attachEvent('on'+on,fn):el.addEventListener(on,fn,false)}, //Function for cross-borwser addEvent move=function(e){ float.style.left=(e=e||window.event).clientX+20+'px'; float.style.top=e.clientY+20+'px'; if(float.nxt!=(e.clientX>(document.body.offsetWidth/2)))float.innerHTML=(float.nxt=!float.nxt)?'':''; //Change html only if needed }, swap=function(e){ var key=(e=e||window.event).type=='MouseOver'?(e.clientX>(document.body.clientWidth/2)?40:37):e.keyCode; if(key>36&&key<41){ var data=scale(key>38?'+1':'-1'),l=data.els.length; for(var i=0;i<l;i++)data.els[i].style.height=i==data.to?'85%':'0px'; } } I've then used a simple imageflip function and implemented it here Code: addEvent(bg,'mouseout',function('BNB_mouseon()'){float.style.display='none'}); //Hide floater when not over image addEvent(bg,'mouseover',function('BNB_mouseon()'){float.style.display='block'}); Where 'bg' stands for the background image div. I've been scratching my head about this for quite a while now, so any advice is appreciated! I'm attempting to impliment it on the website http://www.freddydewemathews.com/, for a little context Hi Guys, I'm wondering if anyone knows of some simple javascript that allows me to create a floating image rollover enlargement, similar to the ones on the homepage of ThemeForest. I've been Googling for hours, so, if anyone knows of a script, i'd be much appreciative. Thanks, Christian Code: var rollnav = []; rollnav[0] = new Image ; rollnav[0].src ="buttons/button 1 suits.png"; rollnav[1] = new Image; rollnav[1].src = "buttons/button 2 suits.png"; rollnav[2] = new Image; rollnav[2].src ="buttons/button 1 dresses.png"; rollnav[3] = new Image; rollnav[3].src ="buttons/button 2 dresses.png"; rollnav[4] = new Image; rollnav[4].src ="buttons/button 1 christening.png"; rollnav[5] = new Image; rollnav[5].src ="buttons/button 2 christening"; rollnav[6] = new Image; rollnav[6].src ="buttons/button 1 Acessories.png"; rollnav[7] = new Image; rollnav[7].src ="buttons/button 2 Acessories.png"; rollnav[8] = new Image; rollnav[8].src ="buttons/button 1 home.png"; rollnav[9] = new Image; rollnav[9].src ="buttons/button 2 home.png"; rollnav[10] = new Image; rollnav[10].src ="buttons/button 1 contact us.png"; rollnav[11] = new Image; rollnav[11].src ="buttons/button 2 contact us.png"; rollnav[12] = new Image; rollnav[12].src ="buttons/button 1 links.png"; rollnav[13] = new Image; rollnav[13].src ="buttons/button 2 links.png"; function SwapOutsuit(){ document.suitnav.src = rollnav[1].src; return true; } function SwapBacksuit(){ document.suitnav.src = rollnav[0].src; return true; } function SwapOutdress(){ document.dressnav.src = rollnav[3].src; return true; } function SwapBackdress(){ document.dressnav.src = rollnav[2].src; return true; } function SwapOutchris(){ document.chrisnav.src = rollnav[5].src; return true; } function SwapBackchris(){ document.chrisnav.src = rollnav[4].src; return true; } function SwapOutaccess(){ document.accessnav.src = rollnav[7].src; return true; } function SwapBackaccess(){ document.accessnav.src = rollnav[6].src; return true; } function SwapOuthome(){ document.homenav.src = rollnav[9].src; return true; } function SwapBackhome(){ document.homenav.src = rollnav[8].src; return true; } function SwapOutcus(){ document.cusnav.src = rollnav[11].src; return true; } function SwapBackcus(){ document.cusnav.src = rollnav[10].src; return true; } function SwapOutlink(){ document.linknav.src = rollnav[13].src; return true; } function SwapBacklink(){ document.linknav.src = rollnav[12].src; return true; } hi im trying to create a series of rollover buttons for my site that can be used on all pages. im using the above array to switch the button images the problem is they all work up until number 9 then they just display the image set as the original image and dont change on mouse over. i try declaring an array with more than 9 spaces it doesn't seem to make a difference ive tried the new array format to with no avail. any help would be greatly appreciated. i have included my code which is embedded in my html to call the function below. Code: <A href="coolkids formal contact us.html" onMouseOver="SwapOutcus()" onMouseOut="SwapBackcus()"><img src="buttons/button 1 contact us.png" name="cusnav" align="left" ></A> <A href="information.html" onMouseOver="SwapOutlink()" onMouseOut="SwapBacklink()"><img src="buttons/button 1 links.png" name="linknav" align="left" ></A> Hi, I'm having a problem getting one of my image rollovers to work, what confuses me is that the other image works fine, I'm trying to get this to work for an assignment here's the javascript: Code: rollImage = new Array() for(i = 0; i < 12; i++){ rollImage[i] = new Image(85,85); } rollImage[0].src = "images/narav2.jpg"; rollImage[1].src = "images/narav3.jpg"; rollImage[2].src = "images/sasuke-avatar-118.jpg"; rollImage[3].src = "images/sasuke.jpg"; function swapNar(img){ //this works fine document.nar11.src = rollImage[img].src; return true; } function returnNar(img){ //this function works fine as well document.nar11.src = rollImage[img].src; return true; } function swapSas(img){ //this function not working document.sasim.src = rollImage(img).src; return true; } function returnSas(img){ //this function also not working document.sasim.src = rollImage(img).src; return true; } Here's the HTML: Code: <tr> <td height="60"> <img src="images/narav2.jpg" name="nar11" width="85" height="85" border="0" id="nar11"/> </td> <td> <a href="naruto.html" onMouseover = "swapNar(1)" onMouseout = "returnNar(0)"> Naruto </a> </td> </tr> <!-- When I mouse over the above link the image rolls over as expected, the bottom link doesn't work as expected and I can't see what I'm doing wrong --> <tr> <td height="60"> <img src="images/sasuke-avatar-118.jpg" name="sasim" width="85" height="85" border="0" id="sasim"/> </td> <td> <a href="sasuke.html" onMouseout= "swapSas(3)" onMouseover= "returnSas(2)"> Sasuke </a> </td> </tr> I can't see what the problem is with the returnSas and swapSas functions, I'm still a noob at this and would really appreciate some assistance, thanks in advance ok I have this image and i want the image to change upon the mouse hovering over it. Which in it self is simple to do and I Google numerous different ways on how to do it. But each one i would be forced to use a <a href... in it. The thing is I don't want to use it cause i am already using HTML image map. I really need help on finding the code that would work... This is what I have Code: <html> <head> </head> <body> <p align="center"><img src="room.bmp" border="1" usemap="#maps" alt="Green room" /></p> <map name="maps"> <area shape="rect" coords="25,210,100,300" href="greenroom.html#energy" > <area shape="rect" coords="130,215,185,277" href="greenroom.html#water"> <area shape="rect" coords="80,11,263,149" href="greenroom.html#tv"> </map> ............. Hello, First of all, I am not a coder. I can put together some fairly simple HTML, and can borrow chunks of JS code to suit certain basic purposes. Also, I am terribly sorry if my technical lingo is way off target. I have managed to accomplish two separate goals using javascript, but am having trouble combining their results. I have created an image link that randomly calls a URL from an array. I also have a separate roll-over image. What I am trying to do is have the link that accesses the array also be a roll-over image. I can't seem to accomplish this. http://matrix.senecac.on.ca/~mlinhar...low/page7.html This URL is what I am working on. The "b" symbol is the roll-over. The "right" arrow accesses an array at: http://matrix.senecac.on.ca/~mlinhar...w/randomize.js I have tried simply adding my roll-over code to randomize.js and adjusting the array accordingly, but that doesn't seem to work. I would like the "right" arrow to be a roll-over image as the "b" symbol is, but also access the "randomize" array as it currently does. My problem is that my understanding of JS isn't great enough to determine how separate pieces of code might be combined or function together. Anyways, I'm sorry if my technical knowledge and abilities are too underdeveloped for this forum. I would appreciate any and all advice anyone might have. Hi I use dreamweaver to build sites, and so don't really have to do much with the code, however adobe cs5 has removed the navigation bar tool and I am totally lost without it. I know Java script is needed... Could anyone help? If someone has some code ,for a vertical navigation bar with 8 buttons, 3 images for each button, buttonup mouse over and button down (which is of course a link to another page), that I could copy and edit, it would help alot! hi, when i mouseon an image, how can i make it so, the image i'm mousingon and a second image both fade into alternate images, and then fade back out to the original images when i mouseoff? here is an example- http://www.javascript-fx.com/develop...t/ifctest.html . any help would be most appreciated.
background: display 3-4 pictures and a generic parargraph. when you mouseover a picture the parargragh changes to the bio of the person pictured and doesn't change until a different picture is mouseovered or a reset butten is clicked. current code: i have adapted some code I found (thank you, donator) to basicly hide and unhide a span ID on mouseover. if functions as i want but the element id is hardcoded and i would like it to be dynamic on mouse location. not being that familair w/ coding and / or javascript; i'm stuck. Code: <script type="text/javascript"> var el; var cpic; //elementId via mouse position window.onload=function() { el=document.getElementById('pic1'); el.onmouseover=function() { changeText('hide','show') } } function changeText(cl1,cl2) { document.getElementById('span1').className=cl1; document.getElementById('span2').className=cl2; } </script> so the above works for 1 image, but as you can see "pic1" is hard coded. i figured i could define "cpic" to takes it's place, but i'm not sure how to get the elementId (i'm assuming it would be from the mouse position). if the above code is totaly the wrong approach let me know. it was just the first thing i found that seemed to do what i needed. on the HTML side "span1" is the default text and "span2" is the hidden mouseover text. i'm assuming that by adding 2 more pictures i'll need to add "span3" and "span4". i'll also have to find a way of hiding the other spans. I.E. if i go from pic2 to pic3 then, the pic2 text will have to be hidden before pic3 text is displayed. one thing i don't want to do is restrict the mouse to be focused on the picture to display the text. the text should change only when another picture is in focus or the rest button is clicked. any direction / suggestions would be a big help. regards, Fatmann66 Hi frds , I have requirement that when ever I hover the mouse on image then the mouse pointer should be hand symbol , So for that I have written the code as <a style="cursor: hand;"> <img ....?</a> in IE it works fine but in Firefox it doesnot works Note : I have already used as <a href="#"> <img ....></a> but due to this , the screen is jumping when we click on image Thanks Raj |