468,306 Members | 1,138 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,306 developers. It's quick & easy.

activating a link

i've got a link that i give focus to via accesskey.

<a href="blah" accesskey=p>

in IE, that just gives it focus, but does not activate it.

how do i activate the link.

thx.
Jun 3 '06 #1
12 3574
ppcguy wrote:
i've got a link that i give focus to via accesskey.

<a href="blah" accesskey=p>

in IE, that just gives it focus, but does not activate it.
how do i activate the link.


The solution below is somewhat hokey, but it works in both Firefox and
IE 6. FF accepts an access key directly on the link (that accesskey=h
is for testing purposes). FF also lets you do
style="visibility:hidden" in the button element instead of
style="width:0px". I expect use of this method is an oversight on the
part of IE and wouldn't rely on it too heavily.

<form action='http://google.com' method=get>
<button type=submit style="width:0px" accesskey=g></button>
<a href="http://google.com" accesskey=h><u>G</u>oogle</a>
</form>

Csaba Gabor from Vienna

Jun 3 '06 #2
VK

ppcguy wrote:
i've got a link that i give focus to via accesskey.

<a href="blah" accesskey=p>

in IE, that just gives it focus, but does not activate it.

how do i activate the link.


<a href="http://www.google.com"
accesskey="t"
onfocus="location.href=this.href">Test</a>

That covers both.

Jun 3 '06 #3
VK wrote:
ppcguy wrote:
i've got a link that i give focus to via accesskey.

<a href="blah" accesskey=p>

in IE, that just gives it focus, but does not activate it.

how do i activate the link.


<a href="http://www.google.com"
accesskey="t"
onfocus="location.href=this.href">Test</a>

That covers both.


Ahem. Let's hope the users are not fans of the tab key. If they are,
they are in for a bit of a surprise. Not to mention clicking on the
link and moving the mouse away before releasing the button.

Csaba

Jun 3 '06 #4
VK
Csaba Gabor wrote:
VK wrote:
<a href="http://www.google.com"
accesskey="t"
onfocus="location.href=this.href">Test</a>

That covers both.
Ahem. Let's hope the users are not fans of the tab key. If they are,
they are in for a bit of a surprise.


Links are included into taborder by default, so navigation by tab
doesn't affect the above method. No surprise.
Not to mention clicking on the
link and moving the mouse away before releasing the button.


"Click" is defined as the sequence of "mousedown"-"mouseup" events on
the same point. So the event above is not clicking and the navigation
by link is not presumed - moreover must be prevented.

Jun 4 '06 #5
VK wrote:
Csaba Gabor wrote:
VK wrote:
<a href="http://www.google.com"
accesskey="t"
onfocus="location.href=this.href">Test</a>

That covers both. Ahem. Let's hope the users are not fans of the tab key. If they are,
they are in for a bit of a surprise.


Links are included into taborder by default,


In some browsers, not others. In some it is a preference setting.

Your method also has the drawback that, having navigated to the new URL,
if the 'back' button is used, the link is still in focus so you go
straight back to the new URL.

Very user-unfriendly.

... so navigation by tab doesn't affect the above method. No surprise.


Big surprise really. Suppose you are tabbing to some other link and on
the way put focus on an 'auto navigate' link - use the back button or
key combo to go back - WTF? You're stuck at the new URL.

Not to mention clicking on the
link and moving the mouse away before releasing the button.


"Click" is defined as the sequence of "mousedown"-"mouseup" events on
the same point. So the event above is not clicking and the navigation
by link is not presumed - moreover must be prevented.


You're right, it's not a click, it's a drag. You completely missed the
point though.

Your solution isn't based on a click, it's based on focus. It will
still navigate to the new URL even though it did not receive a click
event because the link keeps focus.

The whole purpose of dragging a link would be to drop it elsewhere (new
tab, page whatever) and leave the current page at the current URL. But
your method leaves both windows at the new URL.

Really, really user-unfriendly.
--
Rob
Jun 4 '06 #6
VK said the following on 6/4/2006 1:38 AM:
Csaba Gabor wrote:
VK wrote:
<a href="http://www.google.com"
accesskey="t"
onfocus="location.href=this.href">Test</a>

That covers both.

Ahem. Let's hope the users are not fans of the tab key. If they are,
they are in for a bit of a surprise.


Links are included into taborder by default, so navigation by tab
doesn't affect the above method. No surprise.


What is "No surprise" is your lack of the first clue about what the
problem would be.

Hint: Tabbing through the links to get to the next one puts focus on the
link.

I doubt you get the hint and understand it's ramifications so read Rob's
response. I don't care to try to explain common sense to you today.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 4 '06 #7
ppcguy wrote:
i've got a link that i give focus to via accesskey.

<a href="blah" accesskey=p>

in IE, that just gives it focus, but does not activate it.

how do i activate the link.

thx.

May be too late, but it sounds like your question doesnt need a js
solution. In IE hitting ALT + accesskey value will only give focus; you
then have to hit enter to activate it. So, to answer your question
literally, you would do ALT+p+ENTER.

Jun 6 '06 #8
er**********@gmail.com said the following on 6/6/2006 5:47 PM:
ppcguy wrote:
i've got a link that i give focus to via accesskey.

<a href="blah" accesskey=p>

in IE, that just gives it focus, but does not activate it.

how do i activate the link.

thx.

May be too late, but it sounds like your question doesnt need a js
solution. In IE hitting ALT + accesskey value will only give focus; you
then have to hit enter to activate it. So, to answer your question
literally, you would do ALT+p+ENTER.


Or ALT+p+SPACE

Try it :)
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 6 '06 #9
VK
Randy Webb wrote:
VK said the following on 6/4/2006 1:38 AM:
Links are included into taborder by default, so navigation by tab
doesn't affect the above method. No surprise.


What is "No surprise" is your lack of the first clue about what the
problem would be.

Hint: Tabbing through the links to get to the next one puts focus on the
link.


i) nothing is lost for the US soccer team yet - keep watching.

ii) German beer is the best - confirmed so many times, yet again.

iii) Euro Summer weather is much better as I could expect.

iv) The OP task was to navigate to a link on focus - this IMHO clearly
eliminate the option to navigate across the links on the same page
using TAB - really either you shift focus from link to link on TAB or
you navigate away on focus - but you cannot do the both on the same
event (focus). However user friendly it is - it is for OP's
considerations.

Jun 16 '06 #10
Try this:
<a href="blah" id="link1">Link 1 Blah!!!!</a>
<script type="text/javascript">
<!--
window.onkeydown = function(e) {
if (e.altKey && String.fromCharCode(e.keyCode) == 'P') {
document.getElementById('link1').focus();
location.href = document.getElementById('link1').href;
}
}
// -->
</script>

Don't sure it will work, but works in Firefox.

Jun 16 '06 #11
the DtTvB \/\/|20+3:
window.onkeydown = function(e) {


Umm sorry, document.onkeydown is correct.

Jun 16 '06 #12
VK said the following on 6/16/2006 3:23 AM:
Randy Webb wrote:
VK said the following on 6/4/2006 1:38 AM:
Links are included into taborder by default, so navigation by tab
doesn't affect the above method. No surprise. What is "No surprise" is your lack of the first clue about what the
problem would be.

Hint: Tabbing through the links to get to the next one puts focus on the
link.


i) nothing is lost for the US soccer team yet - keep watching.


For whatever that means to you, ok.
ii) German beer is the best - confirmed so many times, yet again.
I don't drink beer so I don't care.
iii) Euro Summer weather is much better as I could expect.
Typical off-topic ramblings today?
iv) The OP task was to navigate to a link on focus - this IMHO clearly
eliminate the option to navigate across the links on the same page
using TAB - really either you shift focus from link to link on TAB or
you navigate away on focus - but you cannot do the both on the same
event (focus). However user friendly it is - it is for OP's
considerations.


You finally got it. And navigating away on focus is a stupid idea.

But alas, it is a typical VK repsonse......
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 17 '06 #13

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Bill | last post: by
3 posts views Thread by Ruskin Hardie | last post: by
1 post views Thread by Jeppe 1971 | last post: by
3 posts views Thread by Spartanicus | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.