Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

I seem to have forgotten how to use javascript...


  • Please log in to reply

#1
kakaze

kakaze

    Member

  • Member
  • PipPip
  • 17 posts
Could aanyone help me out here with a javascript problem I'm having.
Ages ago I learned how to use javascript and never had any problems with it but I'm trying to make a clickable image right now and...I seem to have forgotten it all.
What I've done looks like this:

<html>
<img src="australia.png" usemap="#isles"/>
<map name="isles" id="isles">
<area shape="rect"
coords="13,53,73,165"
href="java script:clicked_on('MAD!');"
title="Test" alt="Tested"/>
</html>

The shape is in the right place alright and is clickable but when I do nothing happens....
Is there some sort of activating javascript at the start you're meant to do? - The trouble I see here is I've got my script command nested in the middle of a bunch of otherwise normal html and I don't want this html taken to be bad javascript code.
Can anyone point out the probally very obvious thing wrong?
  • 0

Advertisements


#2
Major Payne

Major Payne

    Retired Staff

  • Retired Staff
  • 5,307 posts
This is an example of a proper image map:
<div id="header_main"><!-- START Main Header -->
<map name="header">
<area href="index.html" alt="HOME" title="HOME" shape="rect" coords=
"24,97,167,130" />
<area href="games.html" alt="GAMES" title="GAMES" shape="rect" coords=
"170,97,294,130" />
<area href="videos.html" alt="VIDEOS" title="VIDEOS" shape="rect" coords=
"296,97,451,129" />
<area href="contact.html" alt="CONTACT" title="CONTACT" shape="rect" coords=
"453,98,619,129" />
<area href="ideas.html" alt="IDEAS" title="IDEAS" shape="rect" coords=
"621,97,783,130" />
<area href="donate.html" alt="DONATE" title="DONATE" shape="rect" coords=
"785,97,979,130" /></map> 

<img id="header_top" src="images/header.png" title="Mouseover Description" alt="header" usemap="#header" />
</div><!-- END Main Header -->

Another clickable image exaple:
<p><a href="URL path to external link" title="Mouseover Description"><img style="width: XXpx; height: YYpx; border: 0;" src="Path to image" alt="Text Description"></a></p>
You can change the "p" tags to div tags and style as needed to make a nice div container for links.

Edited by Major Payne, 26 July 2009 - 10:51 AM.

  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP