Page 1 of 1

Javascript and links in IE6

Posted: Tue Oct 15, 2002 5:42 pm
by sweahe
Hi!

I thought I could just write a link that calls some javascript and
make it NOT execute the HREF="#" like this:
<a href="#" onclick="toggleOnOff('picture1'); return false">Klick here</a>

This works perfectly (as usual) in Mozilla 1.1, but not in IE 6, where the
page scrolls back up to the top! Why??? Is there a way to avoid this in IE?

/Andreas

Posted: Tue Oct 15, 2002 5:55 pm
by mydimension
i believe that is an IE problem that cannot be circumvented. but alas i don't know the JS DOM so i shall defer to anyone elses take on it.

Posted: Tue Oct 15, 2002 7:18 pm
by volka
try

Code: Select all

<a href="javascript:void(0)" onclick="toggleOnOff('picture1'); return false">Klick here</a>
someone might show me where <a href="#"> --> do nothing is specified

Posted: Wed Oct 16, 2002 1:53 am
by sweahe
That worked, but not if the user is holding down shift when clicking...

For more info about links and javascript, look here:
http://www.evolt.org/article/rating/17/20938/index.html

It's the 'return false' that should make it stop running the HREF...

(IE is a buggy one...)

Posted: Wed Oct 16, 2002 11:11 am
by volka
please excuse me not seeing http://www.evolt.org as authoritative when it comes to html, I thought more of w3.org or similar ;)

Why do you use an uri-anchor (href="..." ) if you do not want to link something?

Posted: Wed Oct 16, 2002 3:53 pm
by sweahe
One strange thing... tried the link in IE5 today and it worked, the page wasn't scrolled to the top! A step back in IE 6 or..?

Why? I guess you can't have a link <a...> without a href attribute or..?

Anyway I made my link work both with javascript enabled browsers and without.

/Andreas

Posted: Wed Oct 16, 2002 4:43 pm
by sweahe
Strange... just discovered that it works perfectly in IE6 on another computer? Same version of browser???? OK... forget it! =)

Posted: Thu Oct 17, 2002 2:14 am
by twigletmac
volka wrote:please excuse me not seeing http://www.evolt.org as authoritative when it comes to html, I thought more of w3.org or similar ;)

Why do you use an uri-anchor (href="..." ) if you do not want to link something?
Have you read the evolt article? The guy who wrote it would agree with you since it is mainly focused on accessibility issues.

sweahe - you really need to find a better way of doing this than with a link that's not a link.

Mac

Posted: Thu Oct 17, 2002 3:06 am
by volka
Have you read the evolt article?
:oops: no I didn't. In some way (I can't figure) evolt-articles temper with my font settings (sets default to smallest font).
The guy who wrote it would agree with you since it is mainly focused on accessibility issues
well then....no...it still stands "not authoritative" Image
:wink:

Posted: Thu Oct 17, 2002 3:13 am
by twigletmac
volka wrote:well then....no...it still stands "not authoritative"
It's an article on creating accessible links using Javascript, ie. making it so that non JS users don't lose out because of poorly designed links and forms, it's full of suggestions but at no point does it claim to be authoritative :roll: .

Mac

Posted: Thu Oct 17, 2002 4:00 am
by volka
just wanted to emphasise my obstinate bullhead again Image

Posted: Thu Oct 17, 2002 8:13 am
by sweahe
sweahe - you really need to find a better way of doing this than with a link that's not a link.
Well, now it's a link... working perfectly with or without javascript.
..and somehow it seems like it's just my IE6 that can't handle return false!??
(so I don't care)