JavaScript - Enlarge Image On Roll Over. (floating)
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 Similar TutorialsHI, I am looking to enlarge an image when its hovered over, can anyone give me the code for this? Thanks 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> 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 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) 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> ............. 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 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 guys, I'm currently developing a simple website with a menu bar. Now this bar consists of several tabs, and I want to enlarge the tabs as soon as the user puts the mouse cursor over it. To illustrate this, here is the menu bar in normal mode: And when the user puts the cursor over the tab "Aktuelles", it should look like this: My idea was to use the jQuery-function .animate(), but the problem is that I use one background image for each tab and it is not possible to resize background images. I also tried to the <img> tag and change the height-attribute in the animate() function, but this doesn't work either. Well I have no idea left how I could solve this. Any help is very welcome. Thanks in advance, enne I have a small .png on my site. I want to view at 250% when I rollover it. Is there a way to have the 250% .png be centered vertically and horizontally where the 100% without making the 100% .png 250% bigger (ex. extra white space). Any recommendations for other ways? 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 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 Could 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. 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 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')); });; }); *********** 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. 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 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! I am not very knowledable in stuff like this, and thought I would try to do it to help out a friend. I found a code from the internet and used it and it works well, but only in a specific resolution. I need to have the nav bar start and a specific point in the page and the code I have uses X and Y coordinates to place it. I can mess with it to get the right coordinates for a certain resolution, but I want it to work for every resolution someone who views it is using. here is the script Code: <script type="text/javascript"> /* Floating Menu script- Roy Whittle (http://www.javascript-fx.com/) Script featured on/available at http://www.dynamicdrive.com/ This notice must stay intact for use */ //Enter "frombottom" or "fromtop" var verticalpos="frombottom" if (!document.layers) document.write('</div>') function JSFX_FloatTopDiv() { var startX = 107, startY = 395; var ns = (navigator.appName.indexOf("Netscape") != -1); var d = document; function ml(id) { var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id]; if(d.layers)el.style=el; el.sP=function(x,y){this.style.left=x;this.style.top=y;}; el.x = startX; if (verticalpos=="fromtop") el.y = startY; else{ el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight; el.y -= startY; } return el; } window.stayTopLeft=function() { if (verticalpos=="fromtop"){ var pY = ns ? pageYOffset : document.body.scrollTop; ftlObj.y += (pY + startY - ftlObj.y)/8; } else{ var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight; ftlObj.y += (pY - startY - ftlObj.y)/8; } ftlObj.sP(ftlObj.x, ftlObj.y); setTimeout("stayTopLeft()", 10); } ftlObj = ml("divStayTopLeft"); stayTopLeft(); } JSFX_FloatTopDiv(); </script> I just need to make it work for every resolution. What the X and Y are set to only work for 1024x768 resolutions. There is a certain spot it needs to start at and if you need the website then please ask if it is needed. So can anyone help? I have this var set: var floatingMenu = { targetX: -270, targetY: 13, hasInner: typeof(window.innerWidth) == 'number', hasElement: document.documentElement && document.documentElement.clientWidth, menu: document.getElementById ? document.getElementById(floatingMenuId) : document.all ? document.all[floatingMenuId] : document.layers[floatingMenuId] }; I want the number to be assigned to targetX (the red part) to be different for Firefox, Chrome or Internet Explorer. How do i do that? I have this var set: var floatingMenu = { targetX: -270, targetY: 13, hasInner: typeof(window.innerWidth) == 'number', hasElement: document.documentElement && document.documentElement.clientWidth, menu: document.getElementById ? document.getElementById(floatingMenuId) : document.all ? document.all[floatingMenuId] : document.layers[floatingMenuId] }; I want the number to be assigned to targetX (the red part) to be different for Firefox, Chrome or Internet Explorer. How do i do that? |