Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help With mouseover javascript menu

Status
Not open for further replies.

Byager

Programmer
Oct 14, 1998
10
US
I need some help. I do not know javascript. I need to be able to produce a pop-up menu when the user puts the mouse over a button or graphic. I have searched some of the Javascript web sites and can not find it. If anyone knows where I can find it or what book to buy that has the base code in it please let me know. I need to have this completed by this weekend. If anyone can help me please email me at <A HREF="mailto:jazzman3@mindspring.com">jazzman3@mindspring.com</A>.<br>
<br>
Thank you all.<br>
<br>
Brian Yager
 
HERE: Example is for 2 images just copy & paste the lines at the bottom for more<br>
<br>
&lt;script language="JavaScript"&gt;<br>
<br>
&lt;!--<br>
function MM_swapImgRestore() { //v2.0<br>
if (document.MM_swapImgData != null)<br>
for (var i=0; i&lt;(document.MM_swapImgData.length-1); i+=2)<br>
document.MM_swapImgData<i>.src = document.MM_swapImgData[i+1];<br>
}<br>
<br>
function MM_preloadImages() { //v2.0<br>
if (document.images) {<br>
var imgFiles = MM_preloadImages.arguments;<br>
if (document.preloadArray==null) document.preloadArray = new Array();<br>
var i = document.preloadArray.length;<br>
with (document) for (var j=0; j&lt;imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){<br>
preloadArray<i> = new Image;<br>
preloadArray[i++].src = imgFiles[j];<br>
} }<br>
}<br>
<br>
function MM_swapImage() { //v2.0<br>
var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;<br>
for (i=0; i &lt; (MM_swapImage.arguments.length-2); i+=3) {<br>
objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];<br>
if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ¦¦<br>
(objStr.indexOf('document.all[') ==0 && document.all ==null))<br>
objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);<br>
obj = eval(objStr);<br>
if (obj != null) {<br>
swapArray[j++] = obj;<br>
swapArray[j++] = (oldArray==null ¦¦ oldArray[j-1]!=obj)?obj.src:eek:ldArray[j];<br>
obj.src = MM_swapImage.arguments[i+2];<br>
} }<br>
document.MM_swapImgData = swapArray; //used for restore<br>
}<br>
//--&gt;<br>
<br>
&lt;/script&gt;<br>
&lt;/head&gt;&lt;script language="JavaScript"&gt;<br>
<br>
<br>
&lt;!-- hide this script from non-javascript-enabled browsers<br>
<br>
if (document.images) {<br>
}<br>
<br>
// stop hiding --&gt;<br>
<br>
<br>
&lt;/script&gt;<br>
<br>
&lt;BODY&gt;<br>
&lt;td&gt;&lt;a href="home.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('document.home','document.home','images/yellow/1b.jpg','a')"&gt;<br>
&lt;img name="home" border="0" src="images/1a.jpg"&gt;&lt;/a&gt;&gt;&lt;/td&gt;<br>
<br>
&lt;td&gt;&lt;a href="home2.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('document.home2','document.home2','images/2b.jpg','a')"&gt;&lt;img name="home2" border="0" src="images/2a.jpg"&gt;&lt;/a&gt;&lt;/td&gt;<br>
&lt;/BODY&gt;<br>
<br>

 
The above script doesn't work. at least on my computer anyway. just thought that I would tell you<br>
<br>
<br>
robacarp.webjump.com/index2.html
 
I was able to get the image to display, but not to get it to switch at the 'mouseover' by placing images called 1a.jpg and 1b.jpg in the same directory as the calling page. I am not a javascript programmer and wonder if this result is because I do not know how to specify a directory in javascript.<br>
<br>
For example, the behavior of the page remains unchanged whether I leave document.home as 'document.home', '', or 'C¦/My Documents/' <br>
<br>
Is this the variable that needs to be changed or have I missed the boat entirely?<br>
<br>
In either case, how would you specify good ol' c:\My Documents in javascript?<br>
<br>
I also noticed that &lt;script langauge=&quot;JavaScript&quot;&gt; is spcified twice. While I can't see how that would affect things...<br>
<br>
Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top