Click to See Complete Forum and Search --> : combining rollover+image+multiple link


stupid_guy
04-25-2003, 11:34 AM
im trying to combine a rollover image and a link which changes more than a frame at a time so that you move over the link the picture changes and when clicked it changes 2 frames but i can't get it to work! here's the code:


<html>
<head>
<title>navagation</title>


<script language="JavaScript" type="text/javascript">

function SwitchImg()
{
var rem, keep=0, store, obj, switcher=new Array, history=document.Data;
for (rem=0; rem < (SwitchImg.arguments.length-2); rem+=3) {
store = SwitchImg.arguments[(navigator.appName == 'Netscape')?rem:rem+1];
if ((store.indexOf('document.layers[')==0 && document.layers==null) ||
(store.indexOf('document.all[')==0 && document.all==null))
store = 'document'+store.substring(store.lastIndexOf('.'),store.length);
obj = eval(store);
if (obj != null) {
switcher[keep++] = obj;
switcher[keep++] = (history==null || history[keep-1]!=obj)?obj.src:history[keep];
obj.src = SwitchImg.arguments[rem+2];
} }
document.Data = switcher;
}

function RestoreImg()
{
if (document.Data != null)
for (var rem=0; rem<(document.Data.length-1); rem+=2)
document.Data[rem].src=document.Data[rem+1];
}


</script>
</head>

<body bgcolor="#330066">
<br>

(here's the simple rollover link)

<a href="home.html" target="main" onMouseOut="RestoreImg()" onMouseOver="SwitchImg('document.lkhome','document.lkhome','txthome.jpg')"><img src="lkhome.jpg" name="lkhome" width="100%" height="15%" alt="Home" border="0"></a>

(here's the rollover + multipe frame changing link which i can't get to work)

<a href="#"
onClick="parent.main.location='pictures.html'
window.location='picsnav.html';">
onMouseOut="RestoreImg()" onMouseOver="SwitchImg('document.lkpic','document.lkpic','txtpic.jpg')"><img src="lkpic.jpg" name="lkpic" width="100%" height="15%" alt="Pictures" border="0"></a>

hope you got what i meant!
:D

havik
04-25-2003, 11:37 AM
Just a quick question, is this a typo (highlighted red)?

<a href="#"
onClick="parent.main.location='pictures.html'
window.location='picsnav.html';">
onMouseOut="RestoreImg()" onMouseOver="SwitchImg('document.lkpic','document.lkpic','txtpic.jpg')"><img src="lkpic.jpg" name="lkpic" width="100%" height="15%" alt="Pictures" border="0"></a>

if it is then thats an error (might not fix the problem but it's still an error :D)

Havik

havik
04-25-2003, 11:39 AM
Try this:

<a href="#"
onClick="parent.main.location='pictures.html'; window.location='picsnav.html';"
onMouseOut="RestoreImg()" onMouseOver="SwitchImg('document.lkpic','document.lkpic','txtpic.jpg')"><img src="lkpic.jpg" name="lkpic" width="100%" height="15%" alt="Pictures" border="0"></a>

Havik

stupid_guy
04-25-2003, 11:49 AM
tried doing that before, but still it dosen't work

havik
04-25-2003, 11:51 AM
does the image rollover work at least? if so, does the code work alone or also when combined with the frame change code?

Havik

stupid_guy
04-25-2003, 11:55 AM
the rollover works and one of the frames changes, it's just that the frame where the link is dosen't change

Jona
04-25-2003, 11:55 AM
Try this:

onClick="top.main.location='pictures.html';
window.location='picsnav.html';"

havik
04-25-2003, 11:55 AM
try this to change 2 frames with one click

put this in head section of the frame that has the link in question

<SCRIPT language="JavaScript">
<!----hide
function change2()
{
parent.ENTERNAMEOFFIRSTFRAME.location="your new frame source";
parent.ENTERNAMEOFSECONDFRAME.location="your new frame soure";
}
//------>
</SCRIPT>

The link:

<a href="javascript:change2()" onMouseOut="RestoreImg()" onMouseOver="SwitchImg('document.lkpic','document.lkpic','txtpic.jpg')"><img src="lkpic.jpg" name="lkpic" width="100%" height="15%" alt="Pictures" border="0"></a>

Let me know if that works

Havik

stupid_guy
04-25-2003, 12:09 PM
still no luck:(

Jona
04-25-2003, 12:10 PM
Helping people with frames is the hardest thing on earth... Did you try my suggestion? If that doesn't work... What browser are you using?

stupid_guy
04-25-2003, 12:27 PM
i tried your suggestion (no luck) and im using internet explorer

havik
04-25-2003, 12:44 PM
That's funny, cause it works on this page:

http://www.pageresource.com/html/frame4.htm

Scroll down to the "Example page" link.

Havik

stupid_guy
04-25-2003, 01:03 PM
one slight difference with that page, theres no rollover image!

Jona
04-25-2003, 01:07 PM
Take off your rollover functions and test it. Then tell us if it works.

havik
04-25-2003, 01:07 PM
It shouldn't matter because if the rollover is working already then all you would need to do is add the code that changes the frames.

Havik

stupid_guy
04-25-2003, 01:19 PM
ok, took the rollover off and it works

Jona
04-25-2003, 01:22 PM
Try putting the onMouseOver before the onMouseOut...

stupid_guy
04-25-2003, 01:26 PM
yayyyyyyyyyyyyyyyyyyyyyy! after getting it to work on it's own then fiddling about with some of your previous suggestions i got it working. Thanks!

Jona
04-25-2003, 01:28 PM
--It's about time, anyways.... :D

havik
04-25-2003, 01:28 PM
Great, I was getting confused as to why isn't wasn't working. :D

Havik