views:

469

answers:

2

I'm using JavaScript to sort a table on an HTML hyperlink:

This sort from Low-to-High:

<a id="asc" href="#" onclick="javascript:sort('asc');">Low</a>

It works great in Firefox/Chrome/Safari but does not work in IE6.

Live site at: http://tinyurl.com/ykzwb2

Click the Sort "High" or Sort "Low" link.

Any idea why it works in all browsers but IE6?

The root cause seems to be that IE6 is not changing the cursor arrow to a small-hand so that the hypertext is even clickable. Right now, when I hover over the links with IE6 - the Sort links are not even clickable

Also, my page passes w3 validation, so that's not the problem

+1  A: 

Try:

<a id="asc" href="javascript:void(0)" onclick="displayHomeListings('asc');">

Or

<a id="asc" href="#" onclick="displayHomeListings('asc');">

Ideally, your click will still do something sensible if JavaScript is disabled on the users browser. In that case,

<a id="asc" href="failsafe.html" onclick="displayHomeListings('asc'); return false;">

Note the return false at the end of the onclick. The stops the href from being visited if the JS succeeds. See this SO post regarding further discussion on that topic.

EDIT:

Now with your additional information in your question about the hand/cursor:

If the cursor is not changing to a hand when hover, this suggests to me you have some sort of invalid HTML, and IE6 is failing to parse the page in the way you expect. Have you tried running it through an HTML validator? Try http://validator.w3.org/.

Matt
Nope, doesn't fix the problem. What's strange is that in IE6, the cursor when hovered over the links remains an arrow and never changes to a small hand. It's like IE6 doesn't even know it's a link
mp_
made an edit - maybe try the second use case with #? Note that I do not have javascript: in the onclick string.
Matt
I don't have an IE6 browser handy, nor do I typically visit tinyurls without knowing whats behind them, but it is possible that IE6 is failing in the JS displayHomeListings(), or even somewhere else. It's a bit more brittle w/ JS than newer browsers.
Matt
Nope. I've tried all 3 of your options. None work. Same problem, IE6 doesn't change the cursor to a 'hand'. Seems like IE6 doesn't know the hyperlink exists.
mp_
I assumed before that what you had up there is just a snippet - because otherwise it is not a valid tag (there is no closing A, or text for the link). If the the HTML is not valid, IE6 may be barfing on that.
Matt
Sorry, didn't copy all of the code. Yep, it's valid. You can even run w3 against the page to show I have no errors.
mp_
Yep, this is a CSS problem though I don't know how to fix it. See my post to @KyleFarris above about the negative margins I removed that fixed the problem but now my HTML doesn't look right
mp_
+1  A: 

Not sure if you are opposed to using jquery, but it tends to work out a lot of these cross-browser incompatibilities.

http://jquery.com

Just a thought.

But, just to add to what Matt is saying, you can try this option to (it usually works in IE):

<a id="asc" href="javascript:displayHomeListings('asc'); void(0);">link</a>

(just remember that it won't work for people without javascript... it just won't do anything...)

KyleFarris
No go. The root problem is that IE6 is not changing the cursor arrow to a small hand so that the hypertext is clickable.
mp_
OHHHH... it might be a CSS problem. IE6 is notoriously bad at CSS. Make sure there are no `position:absolute` elements covering the link. I've had that problem before. In fact, I think I've answered a question on SO about that before.
KyleFarris
It might be your `tabbernav` element.
KyleFarris
@Kyle, ah, good call. Hadn't thought of that
Matt
@KyleFarris, I found the problem but don't know how to fix it. I had a margin-top: -16px on the #listingTabs element. When I removed this negative top margin, it all works now. However, how do I now get the Sort links to horizontally line up with the tabs now?
mp_
@Matt: put the `margin-top` back on there but change the element to be explicitly `position:relative` and then set the `z-index` to something really high, like `z-index:100;`. See what the does.
KyleFarris
@KyleFarris, AWESOME, position:relative fixed it
mp_
@Kyle not sure why I got the mark-as-answer on this. upvoting you since you were the one who actually pointed out the CSS as the potential problem.
Matt
Yeah... that's kinda lame, haha. Thanks Matt.
KyleFarris