Geeks With Blogs
Robert Meyer blog
Although I have a (self imposed) long list of to-do's for a client's site, I've had a gnarly Firefox issue in the back of my mind for a while now.

I wrote a picture gallery application - thumbnails on the side, larger space in the center - click on a thumbnail and get the larger version in the center. Unless yer using Firefox. I used an asp:ImageButton for the thumbnails. I also used a zombie anchor tag to accomodate a call to javascript that keeps the scroll position of a data repeater.

It's taken a big effort to get this site rolling - I mean server issue after server issue (no .Net 2.0 framework - access permission-palooza - the works). After finally ironing out a bunch of (most) of my server issues (actually getting root from the host to get the thing set up) I decided to take a whack at what I assumed (foreshadowing) would be an entirely opaque Firefox problem.

Not that I cared much - I mean, most people use IE - and I could always put a label out there for Firefox users giving them a link to download a real browser (like Opera). I mean - WTF - why can't the Firefox developers make their browser work like the other browser children? Open source snobs.

So fine - I'll give a token effort - probably have to write code just for Firefox - like we're back in the days of a million browsers none too keen on complying with W3C standards (effing hippies).

Turns out, Firefox (Waterweasel?) - she don't like the empty link tag with a blocked href attribute. It's one of the oldest tricks in the book - take an anchor to make an area clickable - put a # as the value for the href attribute - and set up the onclick event (because dollars to donuts that's what you're using a zombie link for).

Here's what the thing looks like in action:
<a href="#" onclick="SomeJavascriptFunction();" />

The Waterweasel - she don't like that. No sir. So I thinks to myself - maybes I puts the onclicks events ins the tables cells definitions (combination Sigmund Freud and Finnish accent). Sho' enuff - Waterweasel starts cooperating. Damn thing still works in IE and Opera, too.

Long story short - took about 10 minutes to debug and test. Better than the usual average amount of lifetimes wacky stuff like this takes.

But now I'm late for work.

Oi veh. Posted on Friday, February 16, 2007 2:09 AM ASP.Net | Back to top


Comments on this post: Firefox - Waterweasel

# re: Firefox - Waterweasel
Requesting Gravatar...
Maybe Firefox would understand your site if you actually coded it properly in the first place.

Silly MicroSoftie, assuming since IE behaves one way and that most people use IE, then IE must be behaving correctly.
Left by Robert on Feb 16, 2007 4:15 AM

# re: Firefox - Waterweasel
Requesting Gravatar...
I'm not sure what effect you're going for, but the anchor tag in your post works the same in FF 1.5 and IE 7.0. Why not put your link text inside the anchor tag, or use href="javascript:myfunction()"?
Left by Carl on Feb 16, 2007 11:41 AM

# re: Firefox - Waterweasel
Requesting Gravatar...
I'm embarassed to share the same name as the first poster. "Maybe FwireFwox wood undahstaaand wah-wah-wah-wah-wahhhhh."

Carl's post, on the other hand proved quite thought provoking.

What I wound up doing was removing the anchor and using the onclick event of a table cell definition. Coulda used a div - whatever.

What I forgot is the ImageButton control has an OnClientClick event that could be helpful. Also, I never thought to put the Javascript call as the value of the href attribute. All of which are things I'll try out.

Thanks for the thought provoking post, Carl.
Left by CodesWithAFist on Feb 16, 2007 5:16 PM

# re: Firefox - Waterweasel
Requesting Gravatar...
"... for Firefox users giving them a link to download a real browser (like Opera)..."

Wow, did you really just say that? Most of the people I know in the coding world write for Firefox, and then go back and correct for issues that IE has. And about %2 actually check to see if Opera works at all.

I think it might be time to drop the ASP.net/IE dependence! Calling Firefox 'not a real browser' when you're using ASPX! I think your priorities are mixed.
Left by Billiam on Jun 22, 2007 2:47 PM

# re: Firefox - Waterweasel
Requesting Gravatar...
if i use :
<asp:ImageButton ... OnClick="ImageButton1_Click"
OnClientClick="this.style.display='none'; return true;" .../>

it work fine on IE but not work in Firefox
plesase YM to me : linhdkl
Some body help me !
Left by linhdkl on Feb 26, 2008 8:15 PM

# re: Firefox - Waterweasel
Requesting Gravatar...
if i use :
&lg;asp:ImageButton ... OnClick="ImageButton1_Click"
OnClientClick="this.style.display='none'; return true;" .../&gt;


it work fine on IE but not work in Firefox
plesase YM to me : linhdkl
Some body help me !
Left by linhdkl on Feb 26, 2008 8:17 PM

# re: Firefox - Waterweasel
Requesting Gravatar...
You're correct in using onclick, but you also have to disable the core anchor functionality if you're going to call some javascript instead of going to another page. You need to include some javascript to prevent the anchor from sending you to # when clicked.

Right after the javascript function you're calling inside onclick, put "return false;" in there, and that should do the trick.
Left by sapp on Jul 09, 2008 7:01 PM

Your comment:
 (will show your gravatar)


Copyright © Robert Meyer | Powered by: GeeksWithBlogs.net