Forum Moderators: open

Message Too Old, No Replies

Degrading onClick to normal HTML <a href=whatever>

         

Nutter

2:56 am on Jul 11, 2005 (gmt 0)

10+ Year Member



I'm working on an image gallery that's using javascript to switch images as well as switch between galleries. But, I'd like it to degrade well when JS is disabled, so I have PHP code that actually builds the page and puts the correct pictures in place depending on the querystring.

Question is: how do I block the <a href=""> from firing if JS is enabled? Right now I have the following

<a href="pagewithquerystrings"><img onClick="javascriptfunction(this);"></a>

I've tried using return false; after the function call, but that just blocks everything.

I'm using FireFox if that matters, but of course it needs to work in as many browsers as possible.

Thanks,
- Ryan

Birdman

3:02 am on Jul 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just put the onclick in the anchor, rather than the img tag.

<a href="pagewithquerystrings" onClick="javascriptfunction(this); return false;><img></a>

That should do the trick.

Nutter

3:14 am on Jul 11, 2005 (gmt 0)

10+ Year Member



I really did try that :-) but it didn't work until I tried it after you suggested it.

Birdman

3:16 am on Jul 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sure ya did ;) Just kidding :) glad it's working now.