Closed Thread Icon

Topic awaiting preservation: Anchor tags and teh onClick event Pages that link to <a href="https://ozoneasylum.com/backlink?for=8716" title="Pages that link to Topic awaiting preservation: Anchor tags and teh onClick event" rel="nofollow" >Topic awaiting preservation: Anchor tags and teh onClick event\

 
Author Thread
Blaise
Nervous Wreck (II) Inmate

From:
Insane since: Jun 2003

posted posted 06-13-2003 08:59

Hi guys, I've encountered a problem and I would like some advice and information on it if possible

I have a couple of Anchor tags on my site surrounding images, they have the onClick event in them which runs a function, eg...

code:
<a href="#" onClick="myFunc();"><img src="image.jpg"></a>



Now this worls fine in all browsers except IE5 and Opera, does anyone have any clues as to why? I've done some searching but have found no news on it.

I've found that if I Change the image to be a button...

code:
<input type="image" onClick="myFunc();">



This works fine and I've got no problem using this method, hell it would probably work if I used...

code:
<a href="javascript:myFunc();"><img src="image.jpg"></a>



But I'm just interested in why my original method didn't work, any clues out there?

Blaise

quisja
Paranoid (IV) Inmate

From: everywhere
Insane since: Jun 2002

posted posted 06-13-2003 10:15

if myFunc is doing anything with the location of the document, maybe even launching a new window, then the browser navigating to the top of the page might override your function. Try putting

code:
onclick="myFunc();return false;"


I'm at a loss otherwise...

« BackwardsOnwards »

Show Forum Drop Down Menu