/    Sign up×
Community /Pin to ProfileBookmark

document.onkeydown in iframe

Hi folks,
I need your help!!

I’m working in a page inside an iframe.
I need to get the user keyboard pressure (ex. F5).
This is my script:

document.onkeydown = function (e){
var intKey = 0;
e= (window.event)? event : e;
intKey = (e.keyCode)? e.keyCode: e.charCode;
switch(intKey) {
case 116: //F5
cambiaAppn();
intKey = 0;
return false;
break;
default:
break;
}
}

In this case cambiaAppn() function is executed but, at the end, browser refresh is executed also with very bad effect!!!

It looks only IE behaviour (Firefox looks good).
Can you help me please?
Thanks in advance.

Stefano

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@KorMay 27.2010 — 

In this case cambiaAppn() function is executed but, at the end, browser refresh is executed also with very bad effect!!![/QUOTE]

We have not the slightest idea what do you mean by bad effect :rolleyes: What happens? What should be and what IE does? We can not guess ?

Can you post a link to a test page ?
Copy linkTweet thisAlerts:
@steve74authorMay 27.2010 — We have not the slightest idea what do you mean by bad effect :rolleyes: What happens? What should be and what IE does? We can not guess ?
[/QUOTE]


Please don't care about "bad effect".

Core of my problem is: "I want to get user F5 pressure without page refresh".

Thanks
Copy linkTweet thisAlerts:
@KorMay 27.2010 — I am afraid that there are some special keys (mainly the Functions) which you can capture their code keys, but [I]you can not prevent their actions[/I], because they are, in fact, controlled by the Operating System. For instance you can not block ALT+F4, nor CTRL+ALT+DEL... I presume F5 could be one of them, at least in IE.
Copy linkTweet thisAlerts:
@steve74authorMay 27.2010 — I am afraid that there are some special keys (mainly the Functions) which you can capture their code keys, but [I]you can not prevent their actions[/I], because they are, in fact, controlled by the Operating System. For instance you can not block ALT+F4, nor CTRL+ALT+DEL... I presume F5 could be one of them, at least in IE.[/QUOTE]

Not at all.

I'll try to be more clear...

If the page is out "iframe" I capture the code key and I prevent the browser action (ex. F5 --> Refresh).

Only in page [U]inside an iframe[/U] I have this behaviour.
×

Success!

Help @steve74 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 6.18,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...