JavaScript - Making Onmouseover Work The First Time Only
Hello all;
I had a quick question about the function onmouseover you can apply to html. I have a slideshow at http://www.tcnj.edu/~intramur/clubsports.php that I want to start when the mouse is moved over the images and to automatically flip through the images after this initial movement. The images are put on a delay in my separate javascript file. However, whenever I move the mouse over the image again, the slideshow jumps ahead. Is there a way to make onmouseover work the first time and then to not work every other time? Similar TutorialsHi all, This is my first post, Self Learned new programmer here :o) Here's what I am having problem with: 1) OnMouseOver is working well on Chrome, but does not do anything on IE. What am I doing wrong? 2) I want to put sound on OnMouseOver. I tried using different examples, but no luck. Can you help me with the code? Here's the full code just in case: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!-- saved from url=(0014)about:internet --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css">td img {display: block;}</style> <!--Fireworks CS5 Dreamweaver CS5 target. Created Fri Nov 19 23:13:18 GMT-0500 (Eastern Standard Time) 2010--> <script language="JavaScript"> <!-- Hide from old browsers if (navigator.appVersion.indexOf("2.") != -1){ check = false; } if ((navigator.appVersion.indexOf("3.") != -1) && (navigator.appName.indexOf("Explorer") != -1)){ check = false; } else { check = true; } image1= new Image(); image1.src = "img/index_r8_c4.gif"; image1on = new Image(); image1on.src = "img/index_r8_c4_RED.gif"; image2= new Image(); image2.src = "img/index_r4_c14.gif"; image2on = new Image(); image2on.src = "img/index_r4_c14_RED.gif"; function imageon(name) { document[name].src = eval(name + "on.src"); } function imageoff(name) { document[name].src = eval(name + ".src"); } function on(name) { if (check == true){ imageon(name); } } function off(name) { if (check == true){ imageoff(name); } } // --> </script> </head> <body background="img/background.jpg"> <table border="0" cellpadding="0" cellspacing="0" width="1025" align="center"> <!-- fwtable fwsrc="main v1.png" fwpage="Page 1" fwbase="index.gif" fwstyle="Dreamweaver" fwdocid = "154491994" fwnested="0" --> <tr> <td><a href="OurPastWork.htm" onmouseover="on('image1');" onmouseout="off('image1')"> <img name="image1" src="img/index_r8_c4.gif" width="279" height="45" border="0" id="index_r8_c4" alt="" /></a></td> <td><a href="OurExperience.htm" onmouseover="on('image2');" onmouseout="off('image2')"> <img name="image2" src="img/index_r4_c14.gif" width="186" height="50" border="0" id="index_r4_c14" alt="" /></a></td> </tr> </table> </body> </html> Thanks in advance Below is code using the onmouseover event, but it doesn't work. The only thing that appears in the status bar is the URL. What am I doing wrong? Code: <a href="http://codingforums.com" onmouseover="window.status='This is an OnMouseOver event'; return true" onmouseout="window.status=' '; return true">Put your mouse here to see status info change at bottom.</a> Hi, this simple code generates a dropdown box with two entries. When I mouseover either of them in Firefox, an image will appear, which then disappears when I mouseout. This won't work in any other browser so far as I can tell, although they all support onmouseover in the option element. Nothing at all happens. Could somebody please try it out and tell me what I am doing wrong? Many thanks. Code: <head> <title>MouseOver test</title> <script type="text/javascript"> function picPW() {document.getElementById("picA").style.visibility="visible";} function picCT() {document.getElementById("picB").style.visibility="visible";} function picOffPW() {document.getElementById("picA").style.visibility="hidden";} function picOffCT() {document.getElementById("picB").style.visibility="hidden";} </script> </head> <body> <select> <option onmouseover="picPW()" onMouseout="picOffPW()">ChoiceA</option> <option onmouseover="picCT()" onMouseout="picOffCT()">Choice B</option> </select> <img id="picA" src="imageA.gif" alt="Choice A" style="visibility: hidden" /> <img id="picB" src="imageB.gif" alt="Choice B" style="visibility: hidden" /> </body> Hi there. Time ago I did come across a rather old but small js library called JQPopUp. it was ideal for a project I am working on (popping out windows with images AND with possibility of CSS styling). I am more skilled at CSS than Javascript and I ignore how to modify it so it works in Firefox. I know that it requires getElementById instead of id's but I don't know how to modify the event.clientX and event.clientY events. Is there anybody there who can lend a hand? The script is below. Thanks a lot... Figaroal PS: also tried to contact author and website... both gone. Code: /************************************************************* * Program : JQPopUp.js * * Purpose : Genereert diverse Popup schermpjes. * * Author : Ron Bausch * * Version 1 : 9 mei 2003 * * Copyright : Ron Bausch * * Website : www.justquick.com * * Email : ron.bausch@wanadoo.nl * **************************************************************/ var bStay=false; var aHelp; var aFields; var iWidth; var sWidth; var sOption; var sHtml; var i,iX,iY,iClX,iClY; var JQPrompt=""; function JQPopUp(sHelptext) { aHelp=sHelptext.split("|"); sWidth=""; iWidth=aHelp[0].length; if (iWidth > 30 && iWidth <= 150) sWidth='width="250"'; else if (iWidth > 150) sWidth='width="375"'; if (!bStay) { if (aHelp.length==1) idHelp.innerHTML='<table '+sWidth+' class="JQColorTable" cellpadding="0" cellspacing="0"><tr><td '+sWidth+' class="JQColorBody" align="center">' + aHelp[0] + '</td></tr></table>'; else if (aHelp.length==2) idHelp.innerHTML='<table '+sWidth+' class="JQColorTable" align="center" cellpadding="0" cellspacing="0"><tr><td>'+aHelp[1]+'</td></tr><tr><td '+sWidth+' class="JQColorBody" align="center">' + aHelp[0] + '</td></tr></table>'; else if (aHelp.length==3) { bStay=true; idHelp.innerHTML= '<table '+sWidth+' class="JQColorTable" cellpadding="0" cellspacing="0">' + '<tr><td><b>'+aHelp[1]+'</b></td></tr><tr><td '+sWidth+' class="JQColorBody" align="center">' + aHelp[0] + '</td></tr>' + '<tr><td class="JQColorBody" align="center"><button class="JQColorTable" onClick="idHelp.style.visibility=\'hidden\'; bStay=false;">'+aHelp[2]+'</button>' + '</td></tr></table>'; } else if (aHelp.length==4) { bStay=true; sOption=aHelp[2].replace(/ /g,""); if (sOption.toUpperCase()=="CONFIRM") { idHelp.innerHTML= '<table '+sWidth+' class="JQColorTable" cellpadding="0" cellspacing="0">' + '<tr><td><b>'+aHelp[1]+'</b></td></tr><tr><td '+sWidth+' class="JQColorBody" align="center">' + aHelp[0] + '</td></tr>' + '<tr><td class="JQColorBody" align="center"><button class="JQColorTable" onClick="'+aHelp[3]+' idHelp.style.visibility=\'hidden\'; bStay=false;">OK</button>' + '<button class="JQColorTable" onClick="idHelp.style.visibility=\'hidden\'; bStay=false;">Cancel</button>' + '</td></tr></table>'; } else if (sOption.toUpperCase()=="PROMPT") { sHtml= '<table '+sWidth+' class="JQColorTable" cellpadding="0" cellspacing="0">' + '<tr><td><b>'+aHelp[1]+'</b></td></tr><tr><td '+sWidth+' class="JQColorBody" align="center">' + aHelp[0] + '</td></tr><tr><td>'+ '<form name="frmJQ">'; aFields=aHelp[3].split(","); for (i=0; i<aFields.length; i++) { sHtml+= '<b>'+aFields[i]+'</b><br>\r<input type="text" name="txt'+aFields[i].replace(/ /g,"")+'" size="30"><br>\r'; } sHtml+= '</tr></td><tr><td class="JQColorBody" align="center"><button name="cmdOK" class="JQColorTable" onClick="JQPrompt=document.forms.frmJQ; idHelp.style.visibility=\'hidden\'; bStay=false;">OK</button>' + '<button name="cmdCancel" class="JQColorTable" onClick="idHelp.style.visibility=\'hidden\'; bStay=false;">Cancel</button>' + '</form></td></tr></table>'; idHelp.innerHTML=sHtml; } else { idHelp.innerHTML= '<table '+sWidth+' class="JQColorTable" cellpadding="0" cellspacing="0">' + '<tr><td><b>'+aHelp[1]+'</b></td></tr><tr><td '+sWidth+' class="JQColorBody" align="center">' + aHelp[0] + '</td></tr>' + '<tr><td class="JQColorBody" align="center"><button class="JQColorTable" onClick="idHelp.style.visibility=\'hidden\'; bStay=false;">'+aHelp[2]+'</button>' + '</td></tr></table>'; } } iClX=event.clientX+10; iClY=event.clientY; iX = document.body.clientWidth - iClX; iY = document.body.clientHeight - iClY; if ( iX < idHelp.offsetWidth) idHelp.style.left = document.body.scrollLeft + iClX - idHelp.offsetWidth; else idHelp.style.left = document.body.scrollLeft + iClX; if (iY < idHelp.offsetHeight) idHelp.style.top = document.body.scrollTop + iClY - idHelp.offsetHeight; else idHelp.style.top = document.body.scrollTop + iClY; idHelp.style.visibility="visible"; idHelp.style.position="absolute"; } } function JQPopOut() { if (!bStay) idHelp.style.visibility="hidden"; } document.write('<span style="visibility:hidden;" id="idHelp"> </span>'); // EOF i'm working with a javascript on a drupal website, but the saving function seems to work only as soon as i click 2 times on the "save" button. the code that fires the function is: Code: var param ="&usuario="+usuario+"&nivel="+nivel+gano+porc_gano+gasto+porc_gasto+tengo+porc_tengo+debo+porc_debo+plazo_debo; var s = document.createElement("script"); s.type = "text/javascript"; s.async = true; s.src = direccion_servidor +"setMisDatos?callback=respuestaGuardarMisDatos¶m="+encodeURIComponent(param); h = document.getElementsByTagName("script")[0]; h.parentNode.insertBefore(s, h); i got the parentNode.insertBefore code from google (the same they use in google analitycs), but still i get error (specifically when he has to do the parentNode.insertBefore part (earlier it was only appendChild, but used to give me the same kind of error. Are the spaces a problem in this sense? Or there might be a better solution? because if i click the second time it enters the setMisDatos function and then works 100%. This is really driving me crazy, can anybody help me? I need help so the specific date & time which the text was saved , appears alongside the text automatically each time a question is asked. It currently just displays the text but NOT DATE OR TIME the text was submitted :/ Thanks a lot in adavance i am just a beginner Here is the coding JSP : Code: <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> <body> <%@ page import="java.util.Vector " %> Enter a news story here <form action=Exercise24.jsp method=post> <textarea name="story" rows=5 cols=100></textarea><br> <input type=submit value="Save"><br><br> </form> All news stories: <jsp:useBean id="nl" class="newspackage.NewsStore" scope="application"/> <jsp:setProperty name="nl" property="story"/> <% Vector<String> theList = nl.getStories(); %> <ol> <% for (int i=0; i < theList.size(); i++) { %> <li> <%= theList.elementAt(i) %> </li> <% } %> </ol> </body> Here is the coding in .java: Code: package newspackage; import java.util.Vector; public class NewsStore { Vector<String> stories = new Vector<String>(); public void setStory(String theNews){ stories.addElement(theNews); } public Vector<String> getStories() { return stories; } } Here is the coding to print the specific time WHICH THE QUESTION WAS ASKED: Code: <%@page contentType="text/html" import="java.util.*" %> <!-- http://www.java-samples.com/jsp --> <html> <body> This question was submitted <%= startTime %>. <br> <%! Date startTime = new Date();%> </body> </html> Hi there, I have a page with 2 navigation menus as well as a slide show (3 separate .js files). I can get them all to work individually but not all together, at the same time. I looked over you FAQ section but I can't seem to figure it out. Any help would be hugely appreciated. Thank you so much. HTML: Quote: <!-- Main content --> <div id="content"> <div style="text-align:center"> <img id="pic" src="images/slideshow/slideshow1.jpg" width="600" height="600" alt="slideshow" /> </div> <script type="text/javascript" src="slideshow.js"></script> </div> <!-- Site navigation menu --> <div id="navcontainer"> <ul> <li> <div align="center"><img src="images/logo1.jpg" id="logo" alt="Logo" /></div> </li> <li><img src="images/buttons/teamandcorpsports1.jpg" id="teamandcorpsports" alt="Team and Corporate Sports" width="224" height="37" /></li> <li><img src="images/buttons/performancesports1.jpg" id="performancesports" alt="Performance Sports" width="224" height="37" /></li> <li><img src="images/buttons/flagsandbanners1.jpg" id="flagsandbanners" alt="Flags and Banners" width="224" height="37" /></li> <li><img src="images/buttons/home1.jpg" id="home" alt="Home" width="224" height="37" /></li> <li><img src="images/buttons/catalogues1.jpg" id="catalogues" alt="Catalogues" width="224" height="37" /></li> <li><img src="images/buttons/galleries1.jpg" id="galleries" alt="Galleries" width="224" height="37" /></li> <li><img src="images/buttons/designown1.jpg" id="designown" alt="Design your Own" width="224" height="37" /></li> </ul> </div> <script type="text/javascript" src="navigation.js"></script> <div id="footer"> <!-- Site navigation menu - footer --> <div id="navcontainer_footer"> <ul> <li><img src="images/buttons/dealerlogin1.jpg" id="dealerlogin" alt="Dealer Log in" width="102" height="29" /></li> <li><img src="images/buttons/contactus1.jpg" id="contactus" alt="Contact Us" width="102" height="29" /></li> <li><img src="images/buttons/dealersignup1.jpg" id="dealersignup" alt="Sign Up to be a Dealer Here" width="102" height="29" /></li> </ul> </div> <script type="text/javascript" src="navigation_bottom.js"></script> </div> </div> <!-- End Wrapper --> slideshow.js Quote: var pause = 3000; // interval, in milliseconds, between transitions var i = 0; // image counter var pic = document.getElementById("pic"); // the <img> element in the HTML file // define an array of images var imgs = new Array("images/slideshow/slideshow1.jpg", "images/slideshow/slideshow2.jpg", "images/slideshow/slideshow3.jpg", "images/slideshow/slideshow4.jpg", "images/slideshow/slideshow5.jpg", "images/slideshow/slideshow6.jpg", "images/slideshow/slideshow7.jpg" ); // preload the images for (var j = 0; j < imgs.length; j++) { var obj = new Image(); obj.src = imgs[j]; } // rotates between the images in the "imgs" array function rotate() { pic.src = imgs[i]; if (i === (imgs.length -1)) { i = 0; } else { i++; } setTimeout("rotate()", pause); } window.onload = rotate; navigation_bottom.js Quote: // define an array of images var navImgs = new Array("images/buttons/dealerlogin1.jpg", "images/buttons/contactus1.jpg", "images/buttons/dealersignup1.jpg"); // preload the images by iterating the array for (var i = 0; i < navImgs.length; i++) { var obj = new Image(); obj.src = navImgs[i]; } // initialize the onmouseover and onmouseout events function init() { // get all the <img> tags in the HTML document as an array var navContainer = document.getElementById("navcontainer_footer"); var imgArray = navContainer.getElementsByTagName("img"); // var imgArray = document.getElementsByTagName("img"); // loop through the array and bind the onmouseout and onmouseover events for (var i = 0; i < imgArray.length; i++) { var img = imgArray[i]; img.onmouseover = doMouseOver; img.onmouseout = doMouseOut; } } // define the function for the onmouseover event function doMouseOver(e) { var img; if (!e) // IE { e = window.event; // get the <img> element for IE that triggered the event img = e.srcElement; } else { // get the <img> element for FF that triggered the event img = e.target; } // extract the digit only from the "id" attribute value and concatenate it // to the image src for a result of "images/pic1.jpg", "images/pic2.jpg" or "images/pic3.jpg" var id = img.id; img.src = "images/buttons/" + id + ".jpg"; //img.src = "images/pic" + id.substring("pic".length) + ".jpg"; } // define the function for the onmouseout event function doMouseOut(e) { var img; if (!e) // IE { e = window.event; // get the <img> element for IE that triggered the event img = e.srcElement; } else { // get the <img> element for FF that triggered the event img = e.target; } //img.src = "images/button_home1.jpg"; var id = img.id; img.src = "images/buttons/" + id + "1.jpg"; } // call the "init" function to initialize the event binding //window.onload = init; navigation.js Quote: // define an array of images var navImgs = new Array("images/buttons/logo1.jpg", "images/buttons/teamandcorpsports1.jpg", "images/buttons/performancesports1.jpg", "images/buttons/flagsandbanners1.jpg", "images/buttons/home1.jpg", "images/buttons/catalogues1.jpg", "images/buttons/galleries1.jpg", "images/buttons/designown1.jpg"); // preload the images by iterating the array for (var i = 0; i < navImgs.length; i++) { var obj = new Image(); obj.src = navImgs[i]; } // initialize the onmouseover and onmouseout events function init() { // get all the <img> tags in the HTML document as an array var navContainer = document.getElementById("navcontainer"); var imgArray = navContainer.getElementsByTagName("img"); // var imgArray = document.getElementsByTagName("img"); // loop through the array and bind the onmouseout and onmouseover events for (var i = 0; i < imgArray.length; i++) { var img = imgArray[i]; img.onmouseover = doMouseOver; img.onmouseout = doMouseOut; } } // define the function for the onmouseover event function doMouseOver(e) { var img; if (!e) // IE { e = window.event; // get the <img> element for IE that triggered the event img = e.srcElement; } else { // get the <img> element for FF that triggered the event img = e.target; } // extract the digit only from the "id" attribute value and concatenate it // to the image src for a result of "images/pic1.jpg", "images/pic2.jpg" or "images/pic3.jpg" var id = img.id; img.src = "images/buttons/" + id + ".jpg"; //img.src = "images/pic" + id.substring("pic".length) + ".jpg"; } // define the function for the onmouseout event function doMouseOut(e) { var img; if (!e) // IE { e = window.event; // get the <img> element for IE that triggered the event img = e.srcElement; } else { // get the <img> element for FF that triggered the event img = e.target; } //img.src = "images/button_home1.jpg"; var id = img.id; img.src = "images/buttons/" + id + "1.jpg"; } // call the "init" function to initialize the event binding //window.onload = init; Hello im using dhtmlx grid in this cells i have from time and to time (i.e ind==1 and ind==2) i need to validate time where to-time must be greater than from-time else it should alert an message,i have writeen a normal Regular expression for the time validation.as the time is i string format i.e[05:00],please can any one send me code for that. Code: var err_str=""; function validate_grid(value,id,ind) { if(ind==1 || ind==2) { var patt=/^([0][0-9]|[1][0-9]|[2][0-3])[:]{1}[0-5][0-9]$/; if(!patt.test(value)) { mygrid.setCellTextStyle(id,ind,"background-color:yellow;"); if(err_str!="") err_str+="\n"+(ind+1)+".Enter numbers and : only.."; else err_str=(ind+1)+".Enter numbers and : only"; return false; } else { mygrid.setCellTextStyle(id,ind,"background-color:white;"); return true; } } } hi im using dhtml xgrid where i need to do validation for time ,(from-time and to-time i.e ind==1 and ind==2 ) to-time must be greater than from-time else i need to alert a message to-time must be greater than from-time. can any one send me the code for it time format is[05:00]. Code: var err_str=""; function validate_grid(value,id,ind) { $("#result").html(" ").show(); if(ind==1 || ind==2) { var patt=/^([0][0-9]|[1][0-9]|[2][0-3])[:]{1}[0-5][0-9]$/; if(!patt.test(value)) { mygrid.setCellTextStyle(id,ind,"background-color:yellow;"); if(err_str!="") err_str+="\n"+(ind+1)+".Enter numbers and : only.."; else err_str=(ind+1)+".Enter numbers and : only"; return false; } else { mygrid.setCellTextStyle(id,ind,"background-color:white;"); return true; } } } Hi Code: var err_str=""; function validate_grid(value,id,ind) { $("#result").html(" ").show(); if(ind==1 || ind==2) { var patt=/^([0][0-9]|[1][0-9]|[2][0-3])[:]{1}[0-5][0-9]$/; if(!patt.test(value)) { mygrid.setCellTextStyle(id,ind,"background-color:yellow;"); if(err_str!="") err_str+="\n"+(ind+1)+".Enter numbers and : only.."; else err_str=(ind+1)+".Enter numbers and : only"; return false; } else { mygrid.setCellTextStyle(id,ind,"background-color:white;"); return true; } } } alert(err-str); here ind==1 is from_time and ind==2 is to_time,i need to validate time as to_time must be always greater than from-time,if condition fails an alert msg should populate.time format is[05:00]as it is in string format im unable to do the validation for it.(ex:from-time=08:00 to-time=07:59 condition fails) thank you. 1 down vote favorite I do have the countdown script (see link below) to display the time between current time and the date given in real-time. However, I want to achieve to display the time difference between a given start and end time. Right now, it calculates from the current server time to the end time. I want to be able to set up my own start time and end time. Here is what I have: http://jsfiddle.net/BgEtE/ thank you for help hi, can some one help me how to get the time and date difference? given two time and date with the following format like in textbox A: 2011-05-03 17:35:47.0 and textbox B: 2011-05-03 16:35:47.0 then the output would be: 0 days, 1 hour, 0 minutes, 0 seconds regards, verve I'm not really a Java writer, so I don't know how to do this myself, though I imagine it would be pretty simple. I am looking to add a script to a webpage that allows users to input a time manually, and have it converted to GMT/Zulu time and display the converted time. I have seen a lot of time zone conversion scripts online, but they all just convert whatever the current system time is to another time zone. I am looking for a script that allows users to convert a time and show the zulu time, for times other than the current time. The time zone the inputed local time would be in is +4:30 (Kabul). I don't really care about style or aestehtics, just a simple script I can insert into a web page to have a time input field. The converted output time can appear in another field, a popup bubble, etc, again style isn't really an issue. It's really just to help people in my job who need to know what the GMT/Zulu time was for certain local times after the fact. One would think it shouldn't be that hard to just subtract 4:30 in your head, but apparently it is. Sorry if just asking for code outright like this is frowned upon. This is my first time doing JavaScript I don't what I did wrong here, but the problem its not showing up the current date and time. Code: <script language = "JavaScript" type="text/javascript"> now = new Date(); localtime = now.toString(); utctime = now.GMTString(); document.wite("<b>localtime</b>" + localtime + "</br>"); document.write("<b>utctime</b>" + utctime); </script> This is what supposed to look like I have tried using different browser chrome,IE9,Maxtor, and Opera my OS is Win7 Hi Guys im new to javascript but i have got this code so far to work Code: <script type="text/javascript"> function do_something(e) { document.getElementById('imgholder') .style.background="transparent url('images/img2.jpg') no-repeat"; } </script> and it works with this Code: <div id="flash"> <div id="imgholder"> </div> <div id="myController2"> <span class="jFlowControl2">No 1 </span> <span class="jFlowControl2">No 2 </span> </div> <div id="mySlides2"> <div> <a onmouseover="do_something(this)" class="vm" href="#" title="Vulnerability Management"></a> <a class="grc" href="#" title="grc"></a> <a class="pci" href="#" title="pci"></a> <a class="gcs" href="#" title="gcs"></a> <a class="pt" href="#" title="Penetration Testing"> </a> <span class="jFlowNext2 NextFlash"> </span> </div> <div> <span class="jFlowPrev2 BackFlash"> </span> </div> </div> </div> Currently the background changes on the 1st link hover. is it possible to have different images load on the hover of different a's? any help would be appricated I have been googling this for two days and am coming to the conclusion that the answer is no. Am I correct?
Alright I know about the problems IE has, but I'm testing out an id that is titled "slideRecord1" and trying to move it. The functions work with Firefox for the onmouseover and onmouseout attributes. But IE doesn't support that. So I'm trying to do it manually in the Javascript, but it's still not reading it. Any help? Code: /* <![CDATA[ */ document.getElementById('slideRecord1').onmouseover = function(){slideRecord(1);} function slideRecord(disc) { var record = "disc"+disc; var y = 20; document.getElementById(record).style.top = y + 'px'; } function unSlideRecord(disc) { record = "disc"+disc; var y = 0; document.getElementById(record).style.top = y + 'px'; } /* ]]> */ I have a img tag but I also added <img src="panada.jpg" onmouseover="alert('$info')"> can you tell me what I'm doing wrong?
Alright, I'm trying to get this website finished within the next 5 hours. I was designing it in such a way that I have some rollover buttons that take me to various parts of the site. Then, I have a gallery page, where I have a simple rollover galley. Adding the rollover gallery has stopped my buttons at the top from working. First, my .js file Code: function swap_image(name,source) { document.images[name].src=source; var argv=swap_image.arguments; if(argv[2] && argv[3] && document.getElementById) { element=document.getElementById(argv[2]); element.innerHTML=argv[3]; } } if (document.images) { image0 = new Image; image1 = new Image; image2 = new Image; image0.src = '/images/male_fem.jpg'; image1.src = '/images/moon_wmn.jpg'; image2.src = '/images/mobydick.jpg'; } else { image0 = ''; image1 = ''; image2 = ''; document.rollimg = ''; } var cap = ['Picture One', 'Second Picture', 'Three']; function rollover(n) { document.rollimg.src = window['image'+n].src; document.getElementById('caption').innerHTML = cap[n]; } Now a portion of my html.. Code: <a onmouseover="swap_image('gallery','/images/galleryro.jpg')" onmouseout="swap_image('gallery','/images/galleryhl.jpg')"> <img style = "top:150px; left:160px;" border="0" id="gallery" src="/images/galleryhl.jpg"/> </a> <a href="timeline.htm" onmouseover="swap_image('timeline','/images/timelinero.jpg')" onmouseout="swap_image('timeline','/images/timeline.jpg')"> <img style = "top:150px; left:175px;" border="0" id="timeline" src="/images/timeline.jpg"/> </a> <a href="biography.htm"onmouseover="swap_image('biography','/images/biographyro.jpg')" onmouseout="swap_image('biography','/images/biography.jpg')"> <img style = "top:150px; left:190px;" border="0" id="biography" src="/images/biography.jpg"/> </a> <a href="contact.htm" onmouseover="swap_image('contact','/images/contactro.jpg')" onmouseout="swap_image('contact','/images/contact.jpg')"> <img style = "top:150px; left:205px;" border="0" id="contact" src="/images/contact.jpg"/> </a> <div class = "lrgimg"> <p align = "center"> <img style = "top:150px" src="images/male_fem.jpg" width="auto" height="auto" border="0" alt="large" name="rollimg" /> </p> </div> <div class = "imgbar"> <p align = "center"><span onmouseover="document.rollimg.src=image0.src;"> <img style = "top:250px" src="images/male_fem_sm.jpg" width="32" height="32" border="0"alt="malefem"/> </span> <span onmouseover="document.rollimg.src=image1.src;"> <img style = "top:250px" src="images/moon_wmn_sm.jpg" width="32" height="32" border="0" alt="moonwmn"/></span> <span onmouseover="document.rollimg.src=image2.src;"> <img style = "top:250px" src="images/mobydick_sm.jpg" width="32" height="32" border="0" alt="mobydick"/></span> </p> </div> </div> Any help to quickly resolve the conflict, would be greatly appreciated. I don't have a lot of time. 2 onmouseover conflict. i cant click menu1-jQuery. can someone help me out. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>灰色CSS+Js实现的下拉菜单代码- www.webdm.cn</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <script language="JavaScript" type="text/javascript"> function $(id){ return document.getElementById(id); } function menu_my(name,num) { var my; my = $(name); if ( my.last == undefined ) { my.last = 1; } var Menu = $("Menu" + name + my.last); var Cont = $("Cont" + name + my.last); Menu.className = ""; Cont.style.display = "none"; var Menu = $("Menu" + name + num); var Cont = $("Cont" + name + num); Menu.className = "selectd"; Cont.style.display = "block"; my.last = num; } </script> <script type="text/javascript"> startList = function() { if (document.all&&document.getElementById) { navRoot = document.getElementById("nav"); for (i=0; i<navRoot.childNodes.length; i++) { node = navRoot.childNodes[i]; if (node.nodeName=="LI") { node.onmouseover=function() { this.className+=" over"; } node.onmouseout=function() { this.className=this.className.replace(" over", ""); } } } } } window.onload=startList; </script> <style type="text/css"> body{ text-align: center; font-size:12px; } #popimg{ WIDTH:770px; margin:0 auto; text-align:center; } #popimg2{ WIDTH:770px; margin:0 auto; text-align:center; z-index:-1; } ul { padding: 0; margin: 0; list-style: none; } li { position:relative; float: left; width: 110px; } li ul { position:absolute; display: none; top: 20px;left:0; } li:hover ul, li.over ul { display: block; } ul li a{ display:block; font-size:12px; border: 1px solid #ccc; padding:3px; margin-right:1px; text-decoration: none; color: #777;background:#eee; } ul li a:hover{ background-color:#f4f4f4; } #test{ clear:both; background-color:#999999; width:769px; height:100px; margin:0 auto; } .menu0307 { OVERFLOW: hidden; ZOOM: 1; HEIGHT: 28px } .menu0307 SPAN { BACKGROUND: url(http://upload.ouliu.net/g/ad2da94515010b2c275a9b4958441e20.png) no-repeat -1000px 0px; FLOAT: left; OVERFLOW: hidden; WIDTH: 125px; LINE-HEIGHT: 300px; HEIGHT: 28px } .menu0307 SPAN#Menuxuehua1 { BACKGROUND-POSITION: 0px 0px } .menu0307 SPAN#Menuxuehua2 { BACKGROUND-POSITION: -125px 0px; WIDTH: 124px } .menu0307 SPAN.selectd#Menuxuehua1 { BACKGROUND-POSITION: 0px -32px } .menu0307 SPAN.selectd#Menuxuehua2 { BACKGROUND-POSITION: -125px -32px } </style> </head> <body> <div id="popimg"> <ul id="nav"> <li><a href="">menu1</a> <ul> <li><a href="/">Ajax/JavaScript</a></li><li><a href="/">ExtJS</a></li><li><a href="/">jQuery</a></li> </ul> </li> <li><a href="">menu2</a> <ul> <li><a href="/">test1</a></li><li><a href="/">test2</a></li><li><a href="/">test3</a></li> </ul> </li> <li><a href="">Ajax</a> <ul> <li><a href="/">CSS</a></li><li><a href="/">HTML</a></li><li><a href="/">editor</a></li> </ul> </li> <li><a href="">menu3</a> <ul> <li><a href="/">media</a></li><li><a href="/">object</a></li><li><a href="/">graphic</a></li> </ul> </li> <li><a href="">menu4</a> <ul> <li><a href="/">Ajax/JavaScript</a></li><li><a href="/">ExtJS</a></li><li><a href="/">jQuery</a></li> </ul> </li> <li><a href="">menu5</a> <ul> <li><a href="/">game</a></li><li><a href="/">programming</a></li><li><a href="/">sale</a></li> </ul> </li> <li><a href="">VC++</a> <ul><li><a href="/">database</a></li><li><a href="/">oracle</a></li><li><a href="/">sql</a></li> </ul> </li> </ul> </div> <div id="popimg2"> <div id="test"> <DIV class=menu0307 id=xuehua> <SPAN class=selectd id=Menuxuehua1 onmouseover="menu_my('xuehua',1)" ;>meeting</SPAN> <SPAN id=Menuxuehua2 onmouseover="menu_my('xuehua',2)" ;>note</SPAN> </DIV> <DIV id=Contxuehua1 style="POSITION: relative">test</DIV> <DIV id=Contxuehua2 style="DISPLAY: none">database</DIV> </div> </div> </body> </html> |