/    Sign up×
Community /Pin to ProfileBookmark

Keypress <Enter> opens URL in _self

Is there a way for me to write Javascript into HTML so that once the page is open, they can hit the enter key to launch a URL as if they clicked a link? I know this can be done. I am a flash developer and can do it in flash, but we need it in HTML with no flash involved. Please help me. i don’t know JS very well and have been researching for hours now! LOL! Let me know ?

Thanks!

-w

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@felgallOct 27.2005 — function kH(e) {
var pK = document.all? window.event.keyCode:e.which;
if (pK == 13) location.href = 'nextpage.html';
}
document.onkeypress = kH;
if (document.layers) document.captureEvents(Event.KEYPRESS);
Copy linkTweet thisAlerts:
@bokehOct 27.2005 — [code=php]<head>
<script type="text/javascript">
document.onkeydown = keyHit

function keyHit(evt) {
if(evt){
thisKey = evt.which;
}else{
thisKey = window.event.keyCode;
}
if(thisKey == '13'){
window.location = 'http://domain.com/';
}


</script>
</head>[/code]
Copy linkTweet thisAlerts:
@WessnessauthorOct 27.2005 — What in these defines the enter key?
Copy linkTweet thisAlerts:
@bokehOct 27.2005 — 13 By the way I edited my post above. Somehow I had posted the wrong piece of code.
Copy linkTweet thisAlerts:
@UltimaterOct 27.2005 — The enter key is key #13 by both the [i]which[/i] and [i]keyCode[/i] count.
×

Success!

Help @Wessness spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...