Javascript Question...

They have: 35 posts

Joined: Aug 2001

If I have an image in one frame can I make it so that when the image is mouseover'd a small indicator (ie: an arrow) appears on top of an image in another frame?

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Is this the same subject as http://www.webmaster-forums.com/showthread.php?s=&threadid=18221 ?

This topic is probably better suited to the Web Page Authoring section. I'm sure one of the mods will be along to sort all that out soon. Wink

As for your question, yes it is possible. Smiling

You'd have to have a function in your first frame with the mouseover images which moves a containing the arrow image to the location derived from the arguments for that function. Laughing out loud

Like so:

<script type="text/javascript">
  function pointArrow(xpos,ypos)
    {
      parent.frame2.images.arrow.style.visibility="visible";
      parent.frame2.images.arrow.style.left=xpos;
      parent.frame2.images.arrow.style.top=ypos;
    }

  function hideArrow()
    {
      parent.frame2.images.arrow.style.visibility="hidden";
    }
</script>

<body>
  <img src="blah" onMouseOver="pointArrow(100,100); onMouseOut="hideArrow();">
  <img src="blah" onMouseOver="pointArrow(150,217); onMouseOut="hideArrow();">
etc etc.
</body>
'

In Frame 2:

<body>
<div id="arrow" name="arrow" style="visibility:hidden; position:absolute; z-index:100;"><img src="arrow.gif"></div>
</body>
'

I think. Laughing out loud

They have: 35 posts

Joined: Aug 2001

Nar the questions are different, this looked like the right place to post sorry Smiling

I have done what you said but I get a run time error.

http://www.centrepointstation.net/test/test.htm

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

That's because you have missed a couple of quotes:

" onMouseOut="hideArrow();" border=0 width="500" height="500">

Smiling

They have: 35 posts

Joined: Aug 2001

I added the quotes in now I get more runtime errors.

http://www.centrepointstation.net/test/test.htm

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Oh, sorry, I should've mentioned this earlier:

Replace "frame2" in the code with the name of the second frame (where you want the arrow to appear). Sticking out tongue
In your case, "frame2" should be "info".

They have: 6 posts

Joined: Apr 2002

hmm well it's all up and no runtime errors but well nothing happens.

(same url)

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Hmm, I still get an error and your code still shows "frame2".

I've cleared my cache so I can't be viewing an older version of the page.

Can you re-upload/update the code? Smiling

And what's with the new username? Sticking out tongue

They have: 6 posts

Joined: Apr 2002

http://www.centrepointstation.net/test/test4.htm

I re-did the test to ultimatley how it will eventually have to look.

But now the image in right.htm (img/map2.gif) does not appear.

The other account wasn't working.

They have: 6 posts

Joined: Apr 2002

btw put yer mouseover the name "Aldalyn" as thats where the onmouseover code is.

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

I'll have a closer look soon, but just quickly:

The qoutes are really messed up here.

Should be

That's the image code for your map, I presume. Well, inside the named arrow, you should have the image of your arrow, and simply leave this map image code outside the .

Like this:

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Ok, the fix for the javascript error your getting is this:

Change parent.frame2.images.arrow.style... to just parent.frame2.arrow.style...

They have: 35 posts

Joined: Aug 2001

cheers mate, it works!

now all I need is to get an answer on the image mapper question in the other forum Smiling

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.