/    Sign up×
Community /Pin to ProfileBookmark

firefox events

with IE no problem to stop events

e.cancelBubble = true;
e.returnValue = false;
if (navigator.appVersion.indexOf(“MSIE”)!=-1){
e.keyCode = 0;
}
return false;

Is there any way to stop keyboard events with firefox ?

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@KorMay 11.2005 — try

if(e.returnValue){

e.returnValue = false;

e.cancelBubble = true;

}

if(e.preventDefault){

e.preventDefault();

e.stopPropagation();

}

...

return false;
Copy linkTweet thisAlerts:
@makinaauthorMay 11.2005 — doesn't work :o
Copy linkTweet thisAlerts:
@KorMay 11.2005 — maybe you should specify:

if(!e){e==event} or something similar... I don't know your whole code and what you intend to do....
Copy linkTweet thisAlerts:
@makinaauthorMay 11.2005 — no it isn't the problem

imagine a page in firefox where you have 2 input

press tab

if you can stop this event (prevent cursor to go to next input)you win lol

but I can't
Copy linkTweet thisAlerts:
@makinaauthorMay 12.2005 — I found the solution !!!

<script language="javascript" type="text/javascript">

document.onkeypress=make;

function make(event){

if (event.keyCode == 9) {

var newEvent = document.createEvent("KeyEvents")

newEvent.initKeyEvent("keypress", true, true, document.defaultView, event.ctrlKey, event.altKey, event.shiftKey, event.metaKey, 0, doit())

event.preventDefault()

event.target.dispatchEvent(newEvent)

}

}

function doit(){

//alert("toto");

}


</script>

<input type="text" value="">

<input type="text" value="">
×

Success!

Help @makina 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.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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