kate_rose Posted February 4, 2008 Share Posted February 4, 2008 I have a really basic question. I am having trouble getting my gif files for a javascript rollover to load (at least I think that is what the problem is). Anyway here is the code <body onload="MM_preloadImages('image/Arrows/yellow_arrow_rollover/yellow_arrow_rollover_r1_c2_f3.gif','image/Arrows/yellow_arrow_rollover/yellow_arrow_rollover_r1_c1_f2.gif');"> The gif files are in a folder called yellow_arrow_rollover which is in the Arrows folder in my image(s) folder. The image folder is in the same folder as the html file I am working on. All this is still just on my computer. None of it has been uploaded to a server. Thanks, Kate Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted February 4, 2008 Share Posted February 4, 2008 There must be something wrong with the rest of your code; because the image load should be instantaneous on your local machine (preloading is not needed locally; if your code is accurate; the image should display in a matter of milliseconds). Quote Link to comment Share on other sites More sharing options...
kate_rose Posted February 5, 2008 Author Share Posted February 5, 2008 Ok . . . Here is what I have done. I created a rollover in fireworks and exported it to dreamweaver. When I preview it in the browser it works just fine. Then I copied the code into the div in the web page I am working on. The only things I really had to change where the image source locations. In the web page the rollover is not working. However the non rolled over image does appear just fine. It is the 2 preloaded images that should appear when the mouse hovers over them that aren't showing up so that is why I thought it was a preload problem. So the only other things I can imagine would be changing it are the following. I do have some css styling on the body as follows body { background-color:#333; margin: 0; padding: 0; } I guess it could also be something about the div containing the rollover (see below) #main_navigation_arrowmain{ overflow: hidden; position: absolute; top: 32px; left: 31px; margin: 0px; padding: 0px; border: 0px; background-image:none; height: 18px; font-size:1px; width: 32px; z-index: 28; } Finally it could be in the javascript after the preload which is supposed to display the rollover (see below) <div id="main_navigation_arrowmain"> <!-------------------------------------------------------> <!------------Yellow Arrow Rollover---------------------> <!-------------------------------------------------------> <table border="0" cellpadding="0" cellspacing="0" width="32"> <!-- fwtable fwsrc="yellow_arrow_rollover.png" fwbase="yellow_arrow_rollover.gif" fwstyle="Dreamweaver" fwdocid = "927909415" fwnested="0" --> <tr> <td><img src="image/spacer.gif" width="16" height="1" border="0" alt="" /></td> <td><img src="image/spacer.gif" width="16" height="1" border="0" alt="" /></td> <td><img src="image/spacer.gif" width="1" height="1" border="0" alt="" /></td> </tr> <tr> <td><a href="javascript:;" onmouseout="MM_swapImgRestore();" onmouseover="MM_swapImage('yellow_arrow_rollover_r1_c2','','yellow_arrow_rollover_r1_c2_f3.gif',1);"><img name="yellow_arrow_rollover_r1_c1" src="image/Arrows/yellow_arrow_rollover/yellow_arrow_rollover_r1_c1.gif" width="16" height="17" border="0" id="yellow_arrow_rollover_r1_c1" alt="" /></a></td> <td><a href="javascript:;" onmouseout="MM_swapImgRestore();" onmouseover="MM_swapImage('yellow_arrow_rollover_r1_c1','','yellow_arrow_rollover_r1_c1_f2.gif',1);"><img name="yellow_arrow_rollover_r1_c2" src="image/Arrows/yellow_arrow_rollover/yellow_arrow_rollover_r1_c2.gif" width="16" height="17" border="0" id="yellow_arrow_rollover_r1_c2" alt="" /></a></td> <td><img src="image/spacer.gif" width="1" height="17" border="0" alt="" /></td> </tr> </table> </div> Maybe it could be in the preload function itself which is in the head of the document. . . (see below) <script language="JavaScript1.2" type="text/javascript"> window.resizeTo(760, 600); function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}} } </script> I don't see the problem but it must be in there somewhere. Thanks again, Kate Normally I use CSS created rollovers but this one was too complex so I am using JS (thus my confusion - Oh yeah & the fact that I am a newbie) Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted February 5, 2008 Share Posted February 5, 2008 Here is the error it's throwing: n.indexOf is not a function MM_findObj(["yellow_arrow_rollover_r1_c2", "", "yellow_arrow_rollover_r1_c2_f3.gif", 1 more...], Document test.html)test.html (line 47) MM_swapImage()test.html (line 55) onmouseover(mouseover clientX=0, clientY=0)test.html (line 1) [break on this error] var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) ... I am not exactly sure why it is working locally and not on your server. Maybe try to remove your current code and put the original code you have saved locally back in it's place; you may have just left something out. Quote Link to comment Share on other sites More sharing options...
kate_rose Posted February 5, 2008 Author Share Posted February 5, 2008 PQ, I am not using a server at all its all just on my computer. I will go back and double check the original code before I pasted it into the page and see if there are any differences though. Since I am sort of new I am not sure how to interpret that error message . . . Do you know?? Back in a few to report on the double check. Kate Quote Link to comment Share on other sites More sharing options...
kate_rose Posted February 5, 2008 Author Share Posted February 5, 2008 Now I am really stumped ??? When I am in dreamweaver & I ask the original file which just has the arrow rollover displayed in it it does a fine job. So I copied and re-replaced all of the code. No change except I noticed some code behind the design when I display it in the browser. I can sort of see what is happening but I have no idea how to fix it. Somehow part of the javascript code in the head section is being displayed behind the design when I ask it to preview in the browser. Specifically it is this bit I have put in bold below function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}} } The bolded part seems to come before any of my other text content and then at the end a bit is repeated this is the part that is underlined in the bold section. I have had dreamweaver quit on me a couple of times with weird errors maybe I need to reinstall it on the computer??? I am pretty new at this but this seems like a really weird bug to come from a coding error. Does this make any sense at all??? Kate Quote Link to comment Share on other sites More sharing options...
kate_rose Posted February 6, 2008 Author Share Posted February 6, 2008 I have reinstalled dreamweaver and double checked everything I could but I am still getting the error. Any advice would be most welcome. What type of syntax error could do this. Please Help! Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted February 6, 2008 Share Posted February 6, 2008 Do you know how to insert code in Dreamweaver; like in the code editing area (I assume it has one; I have never used it before; I right all my code by hand) or do you know how to open html files up in a text editor (like: notepad or wordpad)? If you know how to do this; you can insert a different image preloading script directly into the page - that should work just as good. Google "JavaScript Image Preloaders" and you should be able to find several tutorials/examples/demos on how to preload images with javascript. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.