Starr Duskk
asked on
Using an onclick or javascript in area shape
In this post, it says that I can use an onclick event in an area shape. However, it seems to require a URL, and my onclick event is handling the URL (a popup window). So the second solution shows how to use the javascript in the URL:
http://www.irt.org/script/1609.htm
But it didn't work. The first I clicked and nothing happened. So I setup the javascript with just a simple alert until I could get that to work and that errors.
Here is my code behind:
I tried it with a semicolon at the end, etc. still same error.
The error is:
How can I use javascript or an onclick event without a URL in an area shape?
thanks!
http://www.irt.org/script/1609.htm
<area shape="circle" coords="150,50,35" href="default.htm"
onClick="alert('circle');return false">
<area shape="circle" coords="150,50,35" href="javascript:alert('circle')"
But it didn't work. The first I clicked and nothing happened. So I setup the javascript with just a simple alert until I could get that to work and that errors.
Here is my code behind:
<area shape="rect" coords="528,178,777,341" href="javascript:alert('circle')" >
I tried it with a semicolon at the end, etc. still same error.
The error is:
JavaScript critical error at line 1, column 6 in (unknown source location)
SCRIPT1002: Syntax error
How can I use javascript or an onclick event without a URL in an area shape?
thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am using an image map library which is taking my commands and recoding it into this:
Open in new window
You can see from the picture that it is trying to create the alert but can't handle the apostrophe.
When I build my string for my literal, this works:
onClick=""alert(1);return false""
This does not
onClick=""alert('circle');
But if I swap my apostrophe with my quotes, it seems to work fine now:
onClick='alert(""circle"")
I'll see if I can't get that to work with my real code. thanks!