Closed Bug 279601 Opened 20 years ago Closed 20 years ago

<img> tag onlclick event doesnt work

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 276767

People

(Reporter: nic, Assigned: bugzilla)

Details

User-Agent:       Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
Build Identifier: Mozilla/5.0 Firefox/1.0

the onlick event on an <img> tag doesnt link to the url specified

Reproducible: Always

Steps to Reproduce:
1.create an <img> tag
2.add an onlick event to the tag
3.add a url in the onclick event

Actual Results:  
the img tag is created by when you hover over the image it doesnt allow you to 
click it to link to the url specified

Expected Results:  
it should have created a link to the url specified in the onclick
sorry here's an exact copy of the code:

<img src="images/Out.jpg" onmouseover="flipImage('images/Over.jpg')" 
onmouseout="flipImage('images/Out.jpg')" onclick="window.navigate('index.php?
why.xml')" align="absmiddle" style="cursor:'hand'"/

I found out that if i use <a href> it does work, but why wont it work for 
onclick.
Works for me, please attach a minimized testcase showing this:
https://bugzilla.mozilla.org/attachment.cgi?bugid=279601&action=enter
It will work fine for onclick if you use the DOM standard location.href
property, rather than the IEism window.navigate() method.

*** This bug has been marked as a duplicate of 276767 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
ok so location.href and window.location both link correctly but it still 
doesnt show a hand cursor so that the person can see it is a link.

Also is the bug resolved because window.navigate doesnt work, will this be 
added at some stage or should i just use the above mentioned as a solution?
just another question:
Will the changes i make from window.navigate to window.location work for other 
browsers like Netscape, Netscape 6 etc.
(In reply to comment #5)
> just another question:
> Will the changes i make from window.navigate to window.location work for other 
> browsers like Netscape, Netscape 6 etc.

Yes, and use cursor:pointer to show the hand.
http://w3.org/TR/CSS21/ui.html#cursor-props

This will not work in older IE versions though, so set the pointer first and
then the hand:
<style type="text/css">
.yourImage
{
  cursor:pointer;
  cursor:hand;
}
</style>
You need to log in before you can comment on or make changes to this bug.