Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
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