Referencing an Image's Map's Link's Details

L

Lucanus

Hi All,

I have scoured my JavaScript book, but can't find the answer, so I
hope that you can help...

I have a banner on my webpage, called (creatively) "banner".
This banner uses a map called "bannerMap".
The map has an area called "homeLink".
The area's href is "home.htm".

How do I reference this href?

I have tried:
document.bannerMap.homeLink.href - FAILED
document.banner.bannerMap.homeLink.href - FAILED
document.homeLink.href - FAILED
document.banner.homeLink.href - FAILED

Has anyone tried this before? Is it possible? What is the answer?!

Thanks
Luke
 
L

Lasse Reichstein Nielsen

I have a banner on my webpage, called (creatively) "banner".
This banner uses a map called "bannerMap".
The map has an area called "homeLink".

I assume you mean name="homeLink" or id="homeLink". It is recommended
to use id. Then, if all else fails, you can do
document.getElementById("homeLink")
The area's href is "home.htm".
How do I reference this href?
Try:
document.links['homeLink'].href

document.bannerMap.homeLink.href - FAILED
document.banner.bannerMap.homeLink.href - FAILED
document.homeLink.href - FAILED
document.banner.homeLink.href - FAILED

You shouldn't assume that the name of an element can be used as a
property name of document (or window, or anything except for the
appropriate collections).

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top