Click to See Complete Forum and Search --> : Mouseover with two pictures/linking to two frames
bjorn berger
01-07-2003, 08:44 AM
Hello, I've really no knowledge of Java programming, but still I try to make my family's homepage:
In the frame "top" I have placed pictures of the 4 of us in one cell each (within the same table). My goal is to make a (Java?)script that does as follows:
When MouseOver I would like that "picture1" of (one of us) to change into "picture2" (of the same person) at the same location (actually, this I have managed to solve).
However: When clicking on the picture I would like that two new frames ("content" & "right") to change/open. I manage if only one new frame shall change/open, but not when TWO new frames should change simultaniously.
I'm all together using 6 frames.
Could somebody help with the full code & a little explenation? I will be greatfull! (Actually, it would also be interesting to know how to solve the same problem when three frames or more (multiple frames) should change/open simultaniously.)
Here you go...
<html>
<head>
<title>Setting Two Frames</title>
<script type="text/javascript">
function setFrames (right,left)
{
top.content.document.location.href = right // chage content to the name of your content frame!
document.location.href = left
}
</script>
</head>
<body>
<a href="javascript:setFrames('right2.htm','left2.htm')">Change two frames!</a>
</body>
</html>In the <a href="javascript:setFrames('right2.htm','left2.htm')"> is where you switch where you want the new frames to go to. The first value is the content frame, and the second is the navigation frame (or whatever frame you are currently in) You can make this work for more that two frames by adding this to the script
top.nameofframe.document.location.href = newvalue
and this to the link
<a href="javascript:setFrames('right2.htm','left2.htm','newvalue.htm')">
NOTE: There should be no space between java script: -- It should be one word. I have no idea why these forums do that to it...Annoying :)
bjorn berger
01-07-2003, 09:37 AM
Thank you so much for your reply, pyro (I've tried for so many hours to solve this problem). Fantastic how fast a problem can be solved on the Internet! :)
Haven't tried your code yet, I have to go home from work first (can't wait to go home now...)..
Just to be sure: I have 6 frames:
top (here's the pictures)
left
middle (content)
right_top
right_middle
right_bottom
It's the frames "content" & "right_middle" I want to change, will your code work for this situation?
You want to change content and right_middle with a click from the top frame? If so, the code will have to be a bit different. If you let me know what it is that you need, I'll rewrite it for you. Also let me know the *names* of you frames, that way I can be sure their right.
bjorn berger
01-07-2003, 09:48 AM
Dear pyro, this is VERY kind of you:
Yes, you have understood my problem correct. As far as I can remember it, the name of the frames is equal to the list I wrote in my last reply. OK?
Thank you for solving my problem...!
bjorn berger
01-07-2003, 10:08 AM
Maybe I should comment following:
My problem is probably now to "merge" your "frame-code" with the code that changes from picture1 to picture2 when MoseOver. I don't know how to do this! Do you have a full code for this?
Here is some code for you. The first part of the javascript is where you define you images to preload...These are the ones that you don't originally see.
You will probably be able to see what is going on, but if not, let me know and I'd be happy to help you out.
Cheers
bjorn berger
01-07-2003, 12:46 PM
pyro: I'm very greatful for this! I don't know where in the world you're located, but anyway: Thank you very much, here from Norway!
You are most welcome. I'm over in the US...Nice how the internet brings us together, huh? :D
bjorn berger
01-09-2003, 05:36 PM
Hi pyro, once again: Thank you for your help. However, there seems to be a small bug in your code:
It work just fine for one picture/cell, but the moment I add another line of code for a second picture/cell, the mouseover effect doesn't work anymore (but the frames are opening perfect).
I guess there must be a bug in your code. Do you by any chance have the time to look into this one more time?
I have attached the code so you easily can see the problem.
Can anybody help?
bjorn berger
01-09-2003, 05:49 PM
...another thing about a link that opens with more than one frame:
If the user uses the back button on their browser they have to press two times insted of one to come back to the page they were before they clicked on the link. Is it possible to create a code that avoids this problem?
Ok, your problem is with the image name. Your images need to have different names, so when they are referenced with document.nameofimage.src, it know what you are talking about. And, you had bjorn2.gif, instead of bjorn2.jpg. :D
About having to hit back twice...That is because you go forwad twice, once to the first page you change, and then again to the second. K?
bjorn berger
01-09-2003, 06:47 PM
Ooops! Sorry about that, pyro, this was due to an error writing a test file to you. The problem is still there in the code! Change the file to .jpg and see for yourself!
bjorn berger
01-09-2003, 06:57 PM
Maybe I misunderstood you, pyro, but my images have different names e.g. gro1 & gro2 - is it this you think are not two different names? - If you're meaning something else, could you be kind enough to be concrete and write a specific example of that part of the code to me?
Oops. This was supposed to go with. Sorry. This works.
Originally posted by bjorn berger
Maybe I misunderstood you, pyro, but my images have different names e.g. gro1 & gro2 - is it this you think are not two different names?Not the image filename, the image name as in <img src="" height="" width="" name="this">
and that would correspond to this in your mouseover document.this.src
bjorn berger
01-09-2003, 07:11 PM
Dear pyro, my problem is solved!!!!
Again, thank you so much for your kindness! It's winter here in Norway, but still:
Warm regards,
Bjorn :-)