JavaScript - Help Needed With Swapping Pix Using Onmouseover And Onmouseout
Aloha,
I'm trying to make a page that changes a pic to match the paragraph the user's mouse is over. Page is here, http://rentalocal.thad.com/sample1 The problem I have is that the page reloads the initial image (the map) every time I move my mouse from one list item to the next, before it loads the next pic. It only does this the first time, but it's annoying, slow, and makes my page look bad. I tested it using both Safari and Firefox and got the same results. Does anyone know how I should correct it? TIA, Thad Code: <ul class="borderit" onmouseout="document.getElementById('picture').src='/pic0.jpg'"> <li onmouseover="document.getElementById('picture').src='/pic1.jpg'"> We are picked up at our hotel in Waikiki. We are greeted with aloha, and fresh leis too. Our destinations are numerous, so let's get started! </li> <li onmouseover="document.getElementById('picture').src='/pic2.jpg'"> We drive away from Waikiki toward the Windward side of O'ahu. Along the way, we see Diamond Head. We stop at a scenic lookout for our first pictures of the day. </li> <li onmouseover="document.getElementById('picture').src='/pic3.jpg'"> From there we view at Koko Crater and Hanauma Bay. Next we stop at the Halona Blowhole, where the waves force water through a lava tube and into the sky as high as 30 feet! </li> <li onmouseover="document.getElementById('picture').src='/pic4.jpg'"> We continue along past the amazingly beautiful blue costal waters. Have you ever seen waters so blue? </li> <li onmouseover="document.getElementById('picture').src='/pic5.jpg'"> We are now far from the hustle and bustle of Honolulu and Waikiki. We stop for a visit to one of the many fantastic local beaches, but not for long, we have much more to see! </li> <li onmouseover="document.getElementById('picture').src='/pic6.jpg'"> As we continue we reach a local macadamia nut farm where we stop to buy some flavorful gifts for friends back home. We make more visits to an art gallery, a ranch, a local restaurant for some ono (Hawaiian word for yummy) food. </li> <li onmouseover="document.getElementById('picture').src='/pic7.jpg'"> We make a stop at Laie Point, and learn about its Hawaiian legend. </li> <li onmouseover="document.getElementById('picture').src='/pic8.jpg'"> From there we continue on to the North Shore. We stop at a few of the world-famous beaches and observe some of the day's surfers. We even get a chance to swim with a honu (turtle). </li> <li onmouseover="document.getElementById('picture').src='/pic9.jpg'"> After a stop at a shrimp truck, we get to Hale'iwa Town for some shopping and dining. We get some yummy Matsumoto Shave Ice. </li> <li onmouseover="document.getElementById('picture').src='/pic10.jpg'"> After leaving the North Shore we begin our return the Waikiki. We travel through wonderfully fragrant pineapple fields. We stop at the Dole Plantation and try not to get lost in the world's largest maze. </li> <li onmouseover="document.getElementById('picture').src='/pic11.jpg'"> On our way back to town we visit the National Cemetery at Punchbowl and the State Capitol. </li> <li onmouseover="document.getElementById('picture').src='/pic12.jpg'"> Our final stop is another scenic point for one last view of the day. </li> <li style="margin-bottom:.5em" onmouseover="document.getElementById('picture').src='/pic13.jpg'"> We return to our hotel. Today we saw so many wondrous sights, took countless pictures, heard about Hawaiian history and legend, sampled some local food, discovered some Hawaiian treasures, and learned some Hawaiian language. This will be a memory that we will recall for the rest of our lives. </li> </ul> Similar TutorialsI am trying to get my code to work without using <a> tags and inline html event handlers. I got most of my code laid out so far. But there is a problem I'm having. The way I have it right now for some reason it selects both of my images when I hover over them. I'm trying to get it to only select the one that is currently moused over and change the border and also display a tooltip of the image name that is moused over. When mouse is off image it goes back to normal. When that image is moused over it should display the same image but bigger in my blank image area with the name of the image above it. This image stays until you mouseover another image. Please help I'm stuck. HTML CODE: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title>Image Viewer</title> <meta http-equiv= "content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="icecream.js"></script> </head> <body> <h1>Products</h1> <table name="showProduct"> <tr> <td> <img src="images/blank.jpg" name="show" /> </td> </tr> </table> <table name="productList"> <tr> <td name="products" id="applePie"> <img src="images/Apple_Pie.gif" name="thumb" /> </td> <td name="products" id="banana"> <img src="images/Banana.gif" name="thumb"/> </td> <td name="products"> <img src="images/ButterscotchChips.jpg" name="thumb"/> </td > <td name="products"> <img src="images/Candy.jpg" name="thumb"/> </td> <td name="products"> <img src="images/CandyHearts.jpg" name="thumb"/> </td> <td name="products"> <img src="images/CandyHeartsHard.jpg" name="thumb"/> </td> <td name="products"> <img src="images/Carmel.gif" name="thumb"/> </td> <td name="products"> <img src="images/Carmel_Heath.gif" name="thumb"/> </td> <td name="products"> <img src="images/ChocChips.jpg" name="thumb"/> </td> <td name="products"> <img src="images/Chocolate_Marshmellow.gif" name="thumb"/> </td> </tr> <tr> <td name="products"> <img src="images/Chocolate_AlmondBar.gif" name="thumb"/> </td> <td name="products"> <img src="images/ChocPeanuts.jpg" name="thumb"/> </td> <td name="products"> <img src="images/ChocSprinkles.jpg" name="thumb"/> </td> <td name="products"> <img src="images/CoconutFlakes.jpg" name="thumb"/> </td> <td name="products"> <img src="images/Fudge_Almonds.gif" name="thumb"/> </td> <td name="products"> <img src="images/full_White_Mint.gif" name="thumb"/> </td> <td name="products"> <img src="images/GumDrops.jpg" name="thumb"/> </td> <td name="products"> <img src="images/GummyBears.jpg" name="thumb"/> </td> <td name="products"> <img src="images/GummySharks.jpg" name="thumb"/> </td> <td name="products"> <img src="images/HeartChews.jpg" name="thumb"/> </td> </tr> <tr> <td name="products"> <img src="images/JellyBeans.jpg" name="thumb"/> </td> <td name="products"> <img src="images/MMBits.jpg" name="thumb"/> </td> <td name="products"> <img src="images/Peanut_Butter_Chocolate.gif" name="thumb"/> </td> <td name="products"> <img src="images/PeanutButterChips.jpg" name="thumb"/> </td> <td name="products"> <img src="images/Peanuts.jpg" name="thumb"/> </td> <td name="products"> <img src="images/RainbowDrops.jpg" name="thumb"/> </td> <td name="products"> <img src="images/RainbowSprinkles.jpg" name="thumb"/> </td> <td name="products"> <img src="images/Raspberry_Brownie.gif" name="thumb"/> </td> <td name="products"> <img src="images/RedLicoriceTaffy.jpg" name="thumb"/> </td> <td name="products"> <img src="images/Rich_Chocolate.gif" name="thumb"/> </td> </tr> <tr> <td name="products"> <img src="images/Strawberry.gif" name="thumb"/> </td> <td name="products"> <img src="images/Strawberry_Cheesecake.gif" name="thumb"/> </td> <td name="products"> <img src="images/TaffyChocRasp.jpg" name="thumb"/> </td> <td name="products"> <img src="images/Tiramisu.gif" name="thumb"/> </td> <td name="products"> <img src="images/Vanilla.gif" name="thumb"/> </td> <td name="products"> <img src="images/Vanilla_Cashews.gif" name="thumb"/> </td> <td name="products"> <img src="images/Vanilla_ChocolateChip_PeanutButter_CookieDough.gif" name="thumb"/> </td> <td name="products"> <img src="images/Vanilla_Peaches.gif" name="thumb"/> </td> <td name="products"> <img src="images/Vanilla_Raspberry.gif" name="thumb"/> </td> <td name="products"> <img src="images/WaffleCone_Vanilla.gif" name="thumb"/> </td> </tr> <tr> <td name="products"> <img src="images/WatermellonSlices.jpg" name="thumb"/> </td> <td name="products"> <img src="images/White_Mint.gif" name="thumb"/> </td> <td name="products"> <img src="images/White_Pretzels_almonds_Fudge.gif" name="thumb"/> </td> <td name="products"> <img src="images/WhiteChocChips.jpg" name="thumb"/> </td> <td name="products"> <img src="images/YogurtPeanuts.jpg" name="thumb"/> </td> <td name="products"> <img src="images/YogurtRasins.jpg" name="thumb"/> </td> </tr> </table> </body> </html> JS CODE: Code: window.onload = function() { runInit(); } function runInit() { var thumbnails = document.getElementsByName('thumb'); for (var i=0; i<thumbnails.length; i++) { thumbnails[i].style.width = "75px"; thumbnails[i].style.height = "80px"; } var cells = document.getElementsByName('products'); for (var i=0; i<cells.length; i++) { cells[i].style.borderStyle = "outset"; } var products = document.getElementsByTagName('td'); for (var i=0; i<products.length; i++) { products[i].onmouseover = preloader; products[i].onmouseout = unHighlight; } } function unHighlight() { if (document.getElementById('applePie').onmouseout) { document.getElementById('applePie').style.borderStyle="outset"; } if (document.getElementById('banana').onmouseout) { document.getElementById('banana').style.borderStyle="outset"; } } function preloader() { if (document.images) { var applePie= new Image(75,80); applePie.src="images/Apple_Pie.gif"; if (document.getElementById('applePie').onmouseover) { document.getElementById('applePie').style.borderStyle="inset"; } var banana= new Image(75,80); banana.src="images/Banana.gif"; if (document.getElementById('banana').onmouseover) { document.getElementById('banana').style.borderStyle="inset"; } var blank= new Image(75,80); blank.src="images/blank.jpg"; var butterscotchChips= new Image(75,80); butterscotchChips.src="images/ButterscotchChips.jpg"; var candy= new Image(75,80); candy.src="images/Candy.jpg"; var candyHearts= new Image(75,80); candyHearts.src="images/CandyHearts.jpg"; var candyHeartsHard= new Image(75,80); candyHeartsHard.src="images/CandyHeartsHard.jpg"; var carmel= new Image(75,80); carmel.src="images/Carmel.gif"; var carmelHeath= new Image(75,80); carmelHeath.src="images/Carmel_Heath.gif"; var chocChips= new Image(75,80); chocChips.src="images/ChocChips.jpg"; var chocMarshmellow= new Image(75,80); chocMarshmellow.src="images/Chocolate_Marshmellow.gif"; var chocAlmondBar= new Image(75,80); chocAlmondBar.src="images/Chocolate_AlmondBar.gif"; var chocPeanuts= new Image(75,80); chocPeanuts.src="images/ChocPeanuts.jpg"; var chocSprinkles= new Image(75,80); chocSprinkles.src="images/ChocSprinkles.jpg"; var coconutFlakes= new Image(75,80); coconutFlakes.src="images/CoconutFlakes.jpg"; var fudgeAlmonds= new Image(75,80); fudgeAlmonds.src="images/Fudge_Almonds.gif"; var fullWhiteMint= new Image(75,80); fullWhiteMint.src="images/full_White_Mint.gif"; var gumDrops= new Image(75,80); gumDrops.src="images/GumDrops.jpg"; var gummyBears= new Image(75,80); gummyBears.src="images/GummyBears.jpg"; var gummySharks= new Image(75,80); gummySharks.src="images/GummySharks.jpg"; var heartChews= new Image(75,80); heartChews.src="images/HeartChews.jpg"; var jellyBeans= new Image(75,80); jellyBeans.src="images/JellyBeans.jpg"; var mmBits= new Image(75,80); mmBits.src="images/MMBits.jpg"; var pbChoc= new Image(75,80); pbChoc.src="images/Peanut_Butter_Chocolate.gif"; var pbChips= new Image(75,80); pbChips.src="images/PeanutButterChips.jpg"; var peanuts= new Image(75,80); peanuts.src="images/Peanuts.jpg"; var rbDrops= new Image(75,80); rbDrops.src="images/RainbowDrops.jpg"; var rbSprinkles= new Image(75,80); rbSprinkles.src="images/RainbowSprinkles.jpg"; var raspberryBrownie= new Image(75,80); raspberryBrownie.src="images/Raspberry_Brownie.gif"; var redLicTaffy= new Image(75,80); redLicTaffy.src="images/RedLicoriceTaffy.jpg"; var richChoc= new Image(75,80); richChoc.src="images/Rich_Chocolate.gif"; var strawberry= new Image(75,80); strawberry.src="images/Strawberry.gif"; var sbCheeseCake= new Image(75,80); sbCheeseCake.src="images/Strawberry_Cheesecake.gif"; var taffyChocRasp= new Image(75,80); taffyChocRasp.src="images/TaffyChocRasp.jpg"; var tiramisu= new Image(75,80); tiramisu.src="images/Tiramisu.gif"; var vanilla= new Image(75,80); vanilla.src="images/Vanilla.gif"; var vanCashews= new Image(75,80); vanCashews.src="images/Vanilla_Cashews.gif"; var vanChocChipPBCD= new Image(75,80); vanChocChipPBCD.src="images/Vanilla_ChocolateChip_PeanutButter_CookieDough.gif"; var vanPeaches= new Image(75,80); vanPeaches.src="images/Vanilla_Peaches.gif"; var vanRaspberry= new Image(75,80); vanRaspberry.src="images/Vanilla_Raspberry.gif"; var waffleCone= new Image(75,80); waffleCone.src="images/WaffleCone_Vanilla.gif"; var wmSlices= new Image(75,80); wmSlices.src="images/WatermellonSlices.jpg"; var whiteMint= new Image(75,80); whiteMint.src="images/White_Mint.gif"; var whitePretzels= new Image(75,80); whitePretzels.src="images/White_Pretzels_almonds_Fudge.gif"; var whiteChocChips= new Image(75,80); whiteChocChips.src="images/WhiteChocChips.jpg"; var yogurtPeanuts= new Image(75,80); yogurtPeanuts.src="images/YogurtPeanuts.jpg"; var yogurtRasins= new Image(75,80); yogurtRasins.src="images/YogurtRasins.jpg"; } } Ok, I'm new to these form and I need help with an assignment. Hopefully I'm within the rules here as I most certainly don't want to get stung for plagiarism or cheating. But, here is my issue. I'm struggling with javascript and I can't manage to get this rollover effect working. The HTML side of things should be ok and it's probably a missing semicolon. Code: /* write functions that define the action for each event */ function showTip () { var sidTip; /* obtain access to the HTML tool tip element using id "sidTip" and link it a varialbe named sidTip */ sidTip = document.getElementById("sidTip"); /* display the HTML tool tip element sidTip bying change the value of its CSS property "display" to "inline" */ sidTip.style.display("inline"); } function hideTip () { /* this function hides the tool tip */ var = sidTip; /*first, get access to the tool tip HTML element */ sidTip = document.getElementById("sidTip") /* then, hide the tool tip HTML element by changing its CSS property "display" to "none" */ sidTip.style.display("none"); } function init () { alert("javascript working"); /* the init function links functions to appropriate events of corresponding HTML elements */ /* create a variable named sid */ var = sid; /* get access to the HTML element by its id "sid" and link it to sid */ sid = document.getElementById("sid"); /* link function showTip to the onmouseover event of sid */ onMouseOver = showTip; /* link function hideTip to the onmouseout event of sid */ onMouseOut = hideTip; } /* link function init to the onload event of the window so that function init will be called when the page is loaded */ window.onload = init; /* another random comment belonging to hebdomad */ Heyho. Well I'm rather new to JavaScripting, so don't be harsh on me . Well I'm trying to make a 'onMouseOver & onMouseOut' event, where you hold the cursor over a image, it will change to another. So, here is my code: Code: <A HREF="Home.html" onmouseover="document.but.src='HOME_OVER.PNG'" onmouseout="document.but.src='HOME_BASE.PNG'"> <IMG SRC="Home_BASE.PNG" NAME="but" BORDER="0" ALT="..."> </A> <br> <A HREF="http://city-driving.co.uk" onmouseover="document.but.src='FORUM_OVER.PNG'" onmouseout="document.but.src='FORUM_BASE.PNG'"> <br> <IMG SRC="FORUM_BASE.PNG" NAME="but2" BORDER="0" ALT="..."> </A> It works fine when I use it for 1 picture, but it really mess up when I use it more then 1 time :/. I don't understand why. Probably obvious for you! Looking forward to (hopefully) see a solution . Marius. Hello! I have created a mouseover/mouseout event using 2 images. I am not sure how to add a third image so the mouseover/mouseout event changes images in sequence each time the mouse is passed over the image and keeps cylcing in order. Would you use an array with a for loop counter for this process? Also, how would you call the function? I guess you would place the call in the mouseover where you would normally put the image to be called? Thanks! I need help with making an Image onMouseOver event and onMouseOut event without using <a> tags and inline code in the HTML. I know how to do it with <a> tags and inline already. Not sure how to go about doing this without <a> tags and inline. If someone could give me an example of how to do this using strictly Javascript only, I would greatly appreciate the help. I am also planning on having the Images within a table and assigning functions that execute when the mouse is over the image within the cell and when the mouse is off the image in the cell. So i've written abit of code myself in order to do this: I will have multiple video tags on my website, each of the video tag's will have to be able to play/pause seperatly, so technically speaking only 1 video should be playing at a time, when the user 'onmouseout' it should pause and when the user's gos to another video that other video should start playing. If he move's the cursor out of the video it should stop... The problem is now, i have video A & B. When i go 'onmouseover' video B, video A starts playing. This is how i started coding: 1 . 2 functions for playing/pausing a video tag 2 . Check how many <video> tags are on the page (after load) 3 . Add Event "mouseout" + function to each <video> tag And the actual code: Javascript: Code: /*** FUNCTIONS OM DE MOUSEOVER & OUT TE DOEN WERKEN ***/ function speelFilmpje(){ document.getElementById("filmpke").play(); } function stopFilmpje(){ document.getElementById("filmpke").pause(); } window.onload = function(){ /*** FUNCTION DIE ONMOUSEOVER & OUT FUNCTIE AAN 'VIDEO' TAGS TOEVOEGT ***/ var video = document.getElementsByTagName('video'); var videotags = video.length; //console.log(videotags); for(i=0; i<videotags;i++){ video[i].addEventListener("mouseover", speelFilmpje,false); video[i].addEventListener("mouseout", stopFilmpje,false); }//einde van de functie } HTML: Code: <div id="right_column"> <div id="preview1"> <video width="197" height="81" id="filmpke"> <source src="unknown.ogg" type="video/ogg"> <source src="unknown.mp4" type="video/mp4"> </video> <a href="#">Unknown (2010)</a> </div> <div id="preview1"> <video width="197" height="81" id="filmpke"> <source src="unknown.ogg" type="video/ogg"> <source src="unknown.mp4" type="video/mp4"> </video> <a href="#">Unknown (2010)</a> </div> </div> Any thoughts or information is welcome. I've stumbled upon my own wall of "Lack of knowledge" -_- Here is a javascript/html code that changes a text phrase to something else on mouseover but it doesn't return to its original state before the event happened. The code is below. Thank you for your help. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <script></script> <title>Javascript</title> <style type="text/css"> div { font-family: Georgia } </style> </head> <body> <script type="text/javascript"> function changetext() { var textchange2 = "~Home~" ; var id = document.getElementById("A"); id.innerHTML=textchange2; } </script> <div id="A" onmouseover="changetext();">Home</div> </body> </html> Hi, I'm trying to use one of the free scripts from Javascriptkit.com, and modifying it to work the way I would like it to. Therefore I have cut parts of it out (href refrences and anchor tags). This is an image rollover script that loads an enlarged image onMouseover to " function warp()". This image is 400x300px and is loaded from thumbnail images. The script works fine as it was written, even after my cutting some of it. The problem I have is that I want to add an onMouseout function that will reload the first image when the mouse moves off of the thumbnail. I am just learning coding, and have not been able to get the onMouseout to work, and I've tried everything I can think of, so I'm hoping you will help, my code is Code: <script> /*Rollover effect on different image script- By JavaScript Kit (http://javascriptkit.com) Over 200+ free scripts here! */ function changeimage(towhat){ if (document.images){ document.images.targetimage.src=towhat.src } } function warp(){ } </script> <script language="JavaScript1.1"> var myimages=new Array() function preloadimages(){ for (i=0;i<preloadimages.arguments.length;i++){ myimages[i]=new Image() myimages[i].src=preloadimages.arguments[i] } } preloadimages("img1.jpg","img2.jpg","img3.jpg","img4.jpg","img5.jpg","img6.jpg") </script> <p class="roller"> <"javascript:warp()"><img src="img6.jpg" name="targetimage" border=0><br> <p class="roller"> <img src="image1.jpg" width="121" height="91" alt="" border="1" onMouseover="changeimage(myimages[0],this.image)";onMouseout="changeimage(myimages[5]),this.image)"> <img src="images/thumb2.jpg" width="121" height="91" alt="" border="1" onMouseover="changeimage(myimages[1],this.image)";onMouseout="changeimage(myimages[5],this.image)"> <img src="images/thumb3.jpg" width="121" height="91" alt="" border="1" onMouseover="changeimage(myimages[2],this.image)";onMouseout="changeimage(myimages[5]),this.image)"> <img src="images/thumb4.jpg" width="121" height="91" alt="" border="1" onMouseover="changeimage(myimages[3],this.image)";onMouseout="changeimage(myimages[5]),this.image)"> <img src="images/thumb5.jpg" width="121" height="91" alt="" border="1" onMouseover="changeimage(myimages[4],this.image)";onMouseout="changeimage(myimages[5]),this.image)"> I'm trying to set a timer when someone moves off of an image. When I try my event without the timer there are no problems but it throws syntax or object expected errors (if I play with the quotes some) when I add in the timer. This is inline code on the image. onMouseout="newsTimer = setTimeout("Effect.toggle('news', 'slide')", 500)"; It is likely something simple I am overlooking but I cannot find any answers after a long search. Thank you for any and all help. Hi All!! I am using onmouseover functionality in php & my code is he echo "<a href='#' onmouseover='gettree_nickname($var)'; onmouseout='SetTimeout(gettree_nickname($var),1000);'>lookup a tree</a>"; Though onmouseover works fine,but onmouseout is not working properly. Is there any syntax mistake, or way of using it is not correct, please suggest. Thanks in advance!! I have a test peice of html is set up roughly like this: Code: <div id="bill" onmouseover="javascript: show('bob'); hide('bill');"> <h1>Bill says hi</h1> </div> <div id="bob" style="visibility:hidden; display:none;" onmouseout="javascript: show('bill'); hide('bob');"> <h1>Bob says hi</h1> </div> And my javascript looks like this: Code: function show(elemId) { elem = document.getElementById(elemId); elem.style.visibility = "visible"; elem.style.display = "block"; } function hide(elemId) { elem = document.getElementById(elemId); elem.style.visibility = "hidden"; elem.style.display = "none"; } You can see what it does from the code: When the page loads, it shows the text Bill says hi. When you move the mouse over the text, it changes to Bob says hi. When you move the mouse away from the text, it reverts to Bill says hi. BUT - this only seems to work consistently when the mouse is moved away from the text at slow speed - if you pull the mouse away quickly, it sometimes gets stuck on Bob says hi. Any ideas why? Hi everyone, I am looking for JS script to replace find all the href values on a page and replace those href values matching them with an array of values. my array, lets say is a = {'some.ex.com', 'abc.ex.com/tv', 'some.name.ex.com', 'bcd.ex.com/dir1/dir2/some.jsp' }; etc i want to find all the URLs on a given page, check if each found url matches with any of the values in the array, if match found, just replace only "ex.com" with "example.com" for every match. I am all new to JS and please please help Many thanks Hi everyone, I'm needing some help capturing just the file name rather than the entire path of the SRC on my input type="image". Basically when I hover over an image, the Default Image should change to the image being hovered on. Here is my code, can't quite get it to work. Sorry I'm very new to JavaScript Code: <html> <head> <script language = "Javascript"> function ChangeDefault(src) { //document.frmMain.DefaultImage.src = src <--Doesn't work at all alert(src) //<---Displays the entire file path, want just file name } </script> </head> <body> <form name="frmMain"> <input type="image" name="DefaultImage" SRC="RWDie1.bmp" HEIGHT=110 WIDTH=160 /> <br /> <input type="image" name="img2" SRC="RWDie2.bmp" HEIGHT=110 WIDTH=160 onMouseOver="ChangeDefault(src)" /> <input type="image" name="img3" SRC="RWDie3.bmp" HEIGHT=110 WIDTH=160 onMouseOver="ChangeDefault(src)" /> <input type="image" name="img4" SRC="RWDie4.bmp" HEIGHT=110 WIDTH=160 onMouseOver="ChangeDefault(src)" /> <input type="image" name="img5" SRC="RWDie5.bmp" HEIGHT=110 WIDTH=160 onMouseOver="ChangeDefault(src)" /> </form> </body> </html> Hello, all. I have a common problem, but despite my research I have been unable to find a solution that works for my situation. I have a large image and several thumbnails below it. I am working with a content management system, so I am able to edit the output of the anchor text around the image, the divs around the image, but NOT the actual image string itself. The images do have some classes built into them, but no IDs. Anyways, I want the main image source to change based on the href of the thumbnail below. So if you click on any one of the thumbs, the href for that thumbnail populates as the source for the main image. Here is my code so far: Code: <div class="images" id="big-image"> <a href="dianaminiflash_shop0001-11.jpg"> <img width="500" height="500" src="dianaminiflash_shop0001-11-500x500.jpg" class="attachment-shop_single wp-post-image" /></a> <div class="thumbnails"> <a href="dianamini_en-rose_front1.jpg" title="dianamini_en-rose_front" rel="thumbnails" class="product-thumb first"> <img src="dianamini_en-rose_front1-200x200.jpg" class="attachment-shop_thumbnail" /></a> <a href="diana-mini_fern-green_front1.jpg" class="product-thumb "> <imgsrc="diana-mini_fern-green_front1-200x200.jpg" class="attachment-shop_thumbnail" /></a> <a href="diana-mini_flashkit_white_front1.jpg" class="product-thumb last"> <img src="diana-mini_flashkit_white_front1-200x200.jpg" class="attachment-shop_thumbnail" /></a> </div> </div> One of the things I've tried that has not worked but has been offered up as a solution on this forum and others is: Code: $(".thumbnails a").click( function() { var changeSrc = $(this).attr("href"); $(".attachment-shop_single").attr("src", changeSrc); return false; }); Any suggestions on what I'm doing wrong here? I really appreciate the help in advance. I have selection boxes that when you choose an option an associated picture is supposed to display.. the problem is that with IE i can use whatever attribute i want and i get the desired effect except with the label attribute which happens to be the only attribute (i know of) that firefox will work with... IE still swaps the picture but also changes the text in the selection box to the img url.. here are my codes: Code: function swapImage(){ var theImage2Display = document.comp.caseselect.options[document.comp.caseselect.selectedIndex].label; var imagePlace = document.getElementById("caseimg"); imagePlace.src = theImage2Display; } and in the html Code: <img src="start.jpg" id="caseimg" /> <select name="caseselect" style="width:625px" onchange="Calculate(); swapImage();"> <option label="start.jpg" value="0" selected="true">Case</option> <option label="COOLER MASTER Elite 310red.jpg" value="50">COOLER MASTER Elite 310 Red ($50.00)</option> <option label="COOLER MASTER Elite 310blue.jpg" value="50">COOLER MASTER Elite 310 Blue ($50.00)</option> <option label="COOLER MASTER Elite 310orange.jpg" value="50">COOLER MASTER Elite 310 Orange ($50.00)</option> <option label="COOLER MASTER Elite 310silver.jpg" value="50">COOLER MASTER Elite 310 Silver ($50.00)</option> </select> I'm creating a new thread just for the sake of getting help from other people and getting help fast. Not sure if other people are or will be facing similar problems as I am but I will post this on the forum for other people's sake... I want to make my drop down box similar to the one seen at http://www.gamewearteamsports.com/ The menu links act as normal links but will drop down to a div box when a person hovers over the link. The box will appear when the person hovers it but SHOULD disappear once the person does not hover over the box anymore. So if the person hovers over another link, the box should disappear. I added a delay timeout to one of my div boxes and the box stays alive for a couple of seconds but then closes back up again even though I'm still hovering over it. Any ideas? My js: Code: <script type="text/javascript"> function drop(which) { document.getElementById("drop" + which).style.display = "block"; } function undrop(which) { document.getElementById("drop" + which).style.display = "none"; } </script> My menu links code: Code: <ul id="head1" style="width:940px;"> <li><a href="#" onmouseover="drop(1)">Basketball</a></li> <li><a href="#" onmouseover="drop(2)" onmouseout="undrop(2)">Football</a></li> <li><a href="#" onmouseover="drop(3)" onmouseout="undrop(3)">Volleyball</a></li> <li><a href="#" onmouseover="drop(4)" onmouseout="undrop(4)">Soccer</a></li> <li><a href="#" onmouseover="drop(5)" onmouseout="undrop(5)">Baseball</a></li> <li><a href="#" onmouseover="drop(6)" onmouseout="undrop(6)">Hockey</a></li> <li><a href="#" onmouseover="drop(7)" onmouseout="undrop(7)">Training</a></li> The code I have for the first link: Code: <div id="drop1" onmouseout="setTimeout('undrop(\'1\')', 3000);" style="z-index:3000;"> There's a table with content in it inside the div. There's a </ul> tag that closes out the menu links. I am trying to have a slide show of pictures that are randomly generated stop when the user mouses over the image, I have got everything to work so far except the onmouseover event, even the onmouseout seems to work I don't necessarily need the exact answer but any guidance would be appreciated! <script type="text/javascript"> /* ! [CDATA[ */ setInterval('randomImage()', 4000); //sets the interval of images to show every 4 seconds and runs the function to do so. var imgs = new Array("outdoors.jpg", "kayak.jpg", "fishing.jpg", "scuba.jpg", "biking.jpg"); //the array of images function randomImage() { document.getElementById("image").src = imgs[Math.floor(Math.random()*imgs.length)]; } //the function calls for a random number and applies it to the array of images to show a random picture. /* ]]> */ </script> </head> <body> <p> <img src="outdoors.jpg" width="200" height="200" alt="Random Image" id="image" onmouseover="clearInterval();" onmouseout="randomImage()" /> </p> I am not quite sure what I am doing wrong I've tried mutliple different set ups for the "onmouseover="clearInterval();" and nothing seems to work. I have the below html. In the below code, I have an onmouseover and onmouseout on the parent DIV of three nested DIVs. Whenever I mouse INTO the nested DIVs, the onmouseout event fires for the outermost DIV. Is there a way to prevent this? <html> <head> <script language="JavaScript"> function mouseOnDiv() { alert("mouseon outerDiv"); event.cancelBubble = true; } function mouseOffDiv() { alert("mouseoff outerDiv"); event.cancelBubble = true; } </script> </head> <body> <div style="border:1px solid red; position:absolute" onmouseover="mouseOnDiv()" onmouseout="mouseOffDiv()"> This is some text <div style="border:1px solid blue; position:relative"> This is some text in the middle div <div style="border:1px solid green; position:relative"> <ul> <li>Item 1</li> </ul> </div> </div> </div> </body> </html> Hi, I am having difficulty (tearing my hair out) with this problem. I have written a page as a learning experince for JavaScript. The page is here. The fade in works perfectly for ONLOAD and for ONMOUSEOVER but not for ONMOUSEOUT. The JavaScript code is as follows: Code: var d_opacity ; var e_element ; var t_timeout ; function fadeInElement(s_element_to_fade_in) { d_opacity = 0.25 ; e_element = document.getElementById(s_element_to_fade_in) ; (e_element.style).display = "" ; (e_element.style).opacity = d_opacity ; t_timeout = setTimeout("fadeIn()", 125) ; } function fadeIn() { if (d_opacity == 1.0) { clearTimeout(t_timeout) ; } else { d_opacity += 0.075 ; (e_element.style).opacity = d_opacity ; t_timeout = setTimeout("fadeIn()", 125) ; } } function fadeOutElement(s_element_to_fade_out) { e_element = document.getElementById(s_element_to_fade_out) ; d_opacity = (e_element.style).opacity ; t_timeout = setTimeout("fadeOut()", 125) ; // (e_element.style).display = "none" ; } function fadeOut() { if (d_opacity == 0.25) { clearTimeout(t_timeout) ; (e_element.style).display = "none" ; } else { d_opacity -= 0.075 ; (e_element.style).opacity = d_opacity ; t_timeout = setTimeout("fadeOutn()", 125) ; } } When I use the commented out line in fadeOutElement(), the menu disappears which says to me ONMOUSEOUT is being triggered correctly, but if I do the fading out code, it does nothing. Any help greatly appreciated. I'm trying to figure out how to have the onmouseout only revert an image, if the user hasn't clicked on the image. If that image has been chosen from a dropdown, then even with the rollover effects, I want the clicked choice to remain until another click. Right now, i have: Code: <a href="javascript:passit2('orange')" onMouseover="change1('pic11','image48')" onClick=" change1('pic11','image48'); add_content2('orange');" onMouseout="change1('pic11','image_off');">opposite</a></li> <script> function change1(picName,imgName) { if (document.images) { imgOn=eval(imgName + ".src"); document[picName].src= imgOn; } }</script> |