473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

IE Not Stopping Default Event

Hello,

I'm currently overriding function keys (F1 to F4) to perform other
actions. In order to do this the default popup windows of Help (F1),
Seach(F3) etc must be turned off. In FF it's easy enought to do using
the preventDefault and stopPropagation event functions.

IE's equivalent is supposed to be cancelBubble and returnValue,
however I can not seem to get them to stop no matter what I try.

Can someone please point out my error? The test code is below.

------
var classKeyPressOverride = function(){}
classKeyPressOverride.prototype.toString = function(){ return " Class
Key Press Override "; }
classKeyPressOverride.prototype.attachListener = function( type,
functionCode ){
//Register the listener
var obj = window.document;
if ('addEventListener' in obj) {
obj.addEventListener( type, functionCode, true);
} else if ('attachEvent' in obj) {
obj.attachEvent('on' + type, functionCode );
} else {
alert("Could not add listener");
}
}
//Create an instance and add attach a lister tpe of keydown
var classKP = new classKeyPressOverride();

classKP.attachListener('keydown', function(event){
var ev = event || window.event;

var keyCode = ev.keyCode || ev.which;
alert("aatrying " + keyCode);
var fKeyPressed = false;

//IE won't like the regular ev.DOM_VK_F1 so use keyCode values.
if (keyCode == 112) {
fKeyPressed = true;
alert("ev F1 Pressed");
}else if (keyCode == 113) {
fKeyPressed = true;
alert("F2 Pressed");
}else if (keyCode == 114) {
fKeyPressed = true;
alert("F3 Pressed");
}else if (keyCode == 115) {
fKeyPressed = true;
alert("F4 Pressed");
}

if (fKeyPressed){
//Prevent help menu and other default F1 key functions
if ('stopPropagation' in ev) {
ev.stopPropagation();
ev.preventDefault();
}else{
// Trying to stop the popup windows in IE
//Does not seem to work...
ev.cancelBubble = true;
ev.returnValue = false;
}
}

}
);

Apr 5 '07 #1
6 2636
bl****@worldweb.com wrote :
Hello,

I'm currently overriding function keys (F1 to F4) to perform other
actions.
Wow! How nice of you to do this for/to your users.
In order to do this the default popup windows of Help (F1),
Seach(F3) etc must be turned off.
Wow! The end must justify the means.
In FF it's easy enought to do using
the preventDefault and stopPropagation event functions.
Maybe your code have succeeded in defeating the general purpose of a
sound user-author relationship where the webpage should not alienate the
user. There is such a thing as "do not alienate your users even though
you can/could" guideline, "do not over-power, over-control the users'
control over basic functions, keys," etc.

What's next? Can you remotedly over-ride the On/Off switch button on the
PC of users?
IE's equivalent is supposed to be cancelBubble and returnValue,
Overriding the F1 key is like overriding the 911 phone number and what
it means to a wide majority of normal, reasonable people. Your code may
have succeeded in a global self-defeating strategy.

Gérard
--
Using Web Standards in your Web Pages (Updated Dec. 2006)
http://developer.mozilla.org/en/docs...your_Web_Pages
Apr 5 '07 #2
Hey Gérard,

Thanks for your concern.

If you would have thought about it a little longer you may have
realized that this if for a web application that the general public
does not have access to.

Since users a trained to press the K-Keys for help. It makes perfect
sense to override the Help menu of the browser with the Help Menu of
the application.

Sincerely,
Blaine

On Apr 5, 3:45 pm, Gérard Talbot <newsblahgr...@gtalbot.orgwrote:
bla...@worldweb.com wrote :
Hello,
I'm currently overriding function keys (F1 to F4) to perform other
actions.

Wow! How nice of you to do this for/to your users.
In order to do this the default popup windows of Help (F1),
Seach(F3) etc must be turned off.

Wow! The end must justify the means.
In FF it's easy enought to do using
the preventDefault and stopPropagation event functions.

Maybe your code have succeeded in defeating the general purpose of a
sound user-author relationship where the webpage should not alienate the
user. There is such a thing as "do not alienate your users even though
you can/could" guideline, "do not over-power, over-control the users'
control over basic functions, keys," etc.

What's next? Can you remotedly over-ride the On/Off switch button on the
PC of users?
IE's equivalent is supposed to be cancelBubble and returnValue,

Overriding the F1 key is like overriding the 911 phone number and what
it means to a wide majority of normal, reasonable people. Your code may
have succeeded in a global self-defeating strategy.

Gérard
--
Using Web Standards in your Web Pages (Updated Dec. 2006)http://developer..mozilla.org/en/doc...s_in_your_Web_...

Apr 6 '07 #3
Lee
bl****@worldweb.com said:
>
Hey G=E9rard,

Thanks for your concern.

If you would have thought about it a little longer you may have
realized that this if for a web application that the general public
does not have access to.
What clues did you provide that might have helped anyone to
realize that? The vast majority of posts in this newsgroup
are about internet sites, putting the onus on you few others
to identify your unusual situation.

It doesn't make sense to over-ride browser functionality.
Even if your current users are used to some legacy system,
it makes much more sense to have them adapt to web browser
standards than to try to pervert the browser to fit them.
--

Apr 6 '07 #4
bl****@worldweb.com wrote :
Hey Gérard,

Thanks for your concern.
Thank you for not top-posting in comp.lang.javascript newsgroup.
If you would have thought about it a little longer you may have
realized that this if for a web application that the general public
does not have access to.
Are you actually saying that you did not think of including such vital
info in your original post or are you saying that you assumed that
readers of your post would have been able (or should be able) to read
your mind over the internet, figure out your intentions and missing
information and then establish that your intentions are sound, fair,
legitimate, level-headed and that your application requirements are all
balanced, sensible and above any reproach?
Since users a trained to press the K-Keys for help.
I read your post several times and still don't understand how or why the
F1 key should be replaced by the "K-Keys" for help or why it is a good
idea to replace the F1 key in an intranet application with the "K-keys".

Maybe one day there will be an original urbanist who will redesign color
for street lights and he will use purple or gray for stop instead of red
and he will choose yellow for going across street intersection instead
of green and such colors will only apply to his town, not outside such town.
It makes perfect
sense to override the Help menu of the browser with the Help Menu of
the application.
Your words up there. Not mine.
Sincerely,
Blaine
Fair enough. Good luck.

Gérard
--
Using Web Standards in your Web Pages (Updated Dec. 2006)
http://developer.mozilla.org/en/docs...your_Web_Pages
Apr 8 '07 #5
I just wanted to post the solution for anyone that is interested.

1) If you want to override the 'F1' button in IE you need to attach an
event listener to stop
the default action.
classKP.attachListener('help', classKP.stopPropagation );

2) In IE cancelBubble and returnValue were not stopping the default
actions as specified in the docs, setting the keyCode to 0 then
running the actions stops all the defaults
ev.keyCode = 0;
Below is a working example.
var classKeyPressOverride = function(){}
classKeyPressOverride.prototype.toString = function(){ return " Class
Key Press Override "; }
classKeyPressOverride.prototype.attachListener = function( type,
functionCode ){
//Register the listener

var obj = window.document;
obj.eventParent = this;
if ('addEventListener' in obj) {
obj.addEventListener( type, functionCode, true);

} else if ('attachEvent' in obj) {
obj.attachEvent('on' + type, functionCode );
} else {
alert("Could not add listener");
}
}
classKeyPressOverride.prototype.stopPropagation = function(ev){
if ('stopPropagation' in ev) {
ev.stopPropagation();
ev.preventDefault();
}else{
ev.keyCode = 0;
ev.cancelBubble = true;
ev.returnValue = false;
}
}

//Create an instance and add attach a lister tpe of keydown
var classKP = new classKeyPressOverride();
classKP.attachListener('help', classKP.stopPropagation );
classKP.attachListener('keydown', function(event,parentClass){
var ev = event || window.event;

var keyCode = ev.keyCode || ev.which;
var fKeyPressed = false;

//ev.DOM_VK_F1
if (keyCode == 112) {
fKeyPressed = true;
//alert("ev F1 Pressed");
}else if (keyCode == 113) {
fKeyPressed = true;
//alert("F2 Pressed");
}else if (keyCode == 114) {
fKeyPressed = true;
//alert("F3 Pressed");
}else if (keyCode == 115) {
fKeyPressed = true;
//alert("F4 Pressed");
}

if (fKeyPressed == true){
this.eventParent.stopPropagation(event);
}

}
);


On Apr 7, 10:35 pm, Gérard Talbot <newsblahgr...@gtalbot.orgwrote:
bla...@worldweb.com wrote :
Hey Gérard,
Thanks for your concern.

Thank you for not top-posting in comp.lang.javascript newsgroup.
If you would have thought about it a little longer you may have
realized that this if for a web application that the general public
does not have access to.

Are you actually saying that you did not think of including such vital
info in your original post or are you saying that you assumed that
readers of your post would have been able (or should be able) to read
your mind over the internet, figure out your intentions and missing
information and then establish that your intentions are sound, fair,
legitimate, level-headed and that your application requirements are all
balanced, sensible and above any reproach?
Since users a trained to press the K-Keys for help.

I read your post several times and still don't understand how or why the
F1 key should be replaced by the "K-Keys" for help or why it is a good
idea to replace the F1 key in an intranet application with the "K-keys".

Maybe one day there will be an original urbanist who will redesign color
for street lights and he will use purple or gray for stop instead of red
and he will choose yellow for going across street intersection instead
of green and such colors will only apply to his town, not outside such town.
It makes perfect
sense to override the Help menu of the browser with the Help Menu of
the application.

Your words up there. Not mine.
Sincerely,
Blaine

Fair enough. Good luck.

Gérard
--
Using Web Standards in your Web Pages (Updated Dec. 2006)http://developer..mozilla.org/en/doc...s_in_your_Web_...

Apr 9 '07 #6
Ups I problem with the code above..

The line
this.eventParent.stopPropagation(event)
should be:
classKP.stopPropagation(event);

var classKeyPressOverride = function(){}
classKeyPressOverride.prototype.toString = function(){ return " Class
Key Press Override "; }
classKeyPressOverride.prototype.attachListener = function( type,
functionCode ){
//Register the listener

var obj = window.document;

if ('addEventListener' in obj) {
obj.addEventListener( type, functionCode, true);

} else if ('attachEvent' in obj) {
obj.attachEvent('on' + type, functionCode );
} else {
alert("Could not add listener");
}
}

classKeyPressOverride.prototype.addListener = function(obj, evt, fun,
b) {
var eventPhase = (typeof(b)=='boolean') ? b : false;

if ('addEventListener' in obj) {
obj.addEventListener(evt, fun, eventPhase);
} else if ('attachEvent' in obj) {
obj.attachEvent(evt, fun);
} else {
alert("Could not add listener");
}
}

classKeyPressOverride.prototype.stopPropagation = function(ev){
if ('stopPropagation' in ev) {
ev.stopPropagation();
ev.preventDefault();
}else{
ev.keyCode = 0;
ev.cancelBubble = true;
ev.returnValue = false;
}
}

//Create an instance and add attach a lister tpe of keydown
var classKP = new classKeyPressOverride();
classKP.attachListener('help', classKP.stopPropagation );
classKP.attachListener('keydown', function(event){
var ev = event || window.event;

var keyCode = ev.keyCode || ev.which;
var fKeyPressed = false;

//ev.DOM_VK_F1
if (keyCode == 112) {
fKeyPressed = true;
//alert("ev F1 Pressed");
}else if (keyCode == 113) {
fKeyPressed = true;
//alert("F2 Pressed");
}else if (keyCode == 114) {
fKeyPressed = true;
//alert("F3 Pressed");
}else if (keyCode == 115) {
fKeyPressed = true;
//alert("F4 Pressed");
}

if (fKeyPressed == true){
//new classKeyPressOverride().stopPropagation(event);

//Use the variable name of the class instance
//Since it is within the scopt of this function code
// "this" and "parent" refer to the object that the key lister is
run on ie window.document
classKP.stopPropagation(event);
}
}
);


On Apr 9, 11:04 am, "bla...@worldweb.com" <bla...@worldweb.comwrote:
I just wanted to post the solution for anyone that is interested.

1) If you want to override the 'F1' button in IE you need to attach an
event listener to stop
the default action.
classKP.attachListener('help', classKP.stopPropagation );

2) In IE cancelBubble and returnValue were not stopping the default
actions as specified in the docs, setting the keyCode to 0 then
running the actions stops all the defaults
ev.keyCode = 0;

Below is a working example.

var classKeyPressOverride = function(){}
classKeyPressOverride.prototype.toString = function(){ return " Class
Key Press Override "; }
classKeyPressOverride.prototype.attachListener = function( type,
functionCode ){
//Register the listener

var obj = window.document;
obj.eventParent = this;
if ('addEventListener' in obj) {
obj.addEventListener( type, functionCode, true);

} else if ('attachEvent' in obj) {
obj.attachEvent('on' + type, functionCode );
} else {
alert("Could not add listener");
}}

classKeyPressOverride.prototype.stopPropagation = function(ev){
if ('stopPropagation' in ev) {
ev.stopPropagation();
ev.preventDefault();
}else{
ev.keyCode = 0;
ev.cancelBubble = true;
ev.returnValue = false;
}

}

//Create an instance and add attach a lister tpe of keydown
var classKP = new classKeyPressOverride();
classKP.attachListener('help', classKP.stopPropagation );
classKP.attachListener('keydown', function(event,parentClass){
var ev = event || window.event;

var keyCode = ev.keyCode || ev.which;
var fKeyPressed = false;

//ev.DOM_VK_F1
if (keyCode == 112) {
fKeyPressed = true;
//alert("ev F1 Pressed");
}else if (keyCode == 113) {
fKeyPressed = true;
//alert("F2 Pressed");
}else if (keyCode == 114) {
fKeyPressed = true;
//alert("F3 Pressed");
}else if (keyCode == 115) {
fKeyPressed = true;
//alert("F4 Pressed");
}

if (fKeyPressed == true){
this.eventParent.stopPropagation(event);
}

}

);

On Apr 7, 10:35 pm, Gérard Talbot <newsblahgr...@gtalbot.orgwrote:
bla...@worldweb.com wrote :
Hey Gérard,
Thanks for your concern.
Thank you for not top-posting in comp.lang.javascript newsgroup.
If you would have thought about it a little longer you may have
realized that this if for a web application that the general public
does not have access to.
Are you actually saying that you did not think of including such vital
info in your original post or are you saying that you assumed that
readers of your post would have been able (or should be able) to read
your mind over the internet, figure out your intentions and missing
information and then establish that your intentions are sound, fair,
legitimate, level-headed and that your application requirements are all
balanced, sensible and above any reproach?
Since users a trained to press the K-Keys for help.
I read your post several times and still don't understand how or why the
F1 key should be replaced by the "K-Keys" for help or why it is a good
idea to replace the F1 key in an intranet application with the "K-keys".
Maybe one day there will be an original urbanist who will redesign color
for street lights and he will use purple or gray for stop instead of red
and he will choose yellow for going across street intersection instead
of green and such colors will only apply to his town, not outside such town.
It makes perfect
sense to override the Help menu of the browser with the Help Menu of
the application.
Your words up there. Not mine.
Sincerely,
Blaine
Fair enough. Good luck.
Gérard
--
Using Web Standards in your Web Pages (Updated Dec. 2006)http://developer.mozilla.org/en/docs...s_in_your_Web_...

Apr 10 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: CG | last post by:
Hi I have developed a Windows Service When I try to start the Service it tells me that it cannot start as there may not be any work to do When I comment out below line of code in my OnStart...
0
by: Daniel O'Brien | last post by:
Hi - any help with this would be greatly appreicated - it has already had me confused for a good few hours! I am using Visual Studio 2003 and the .NET framework 1.1. I have a C# Windows...
8
by: saif | last post by:
Hi all, I realy need your help. I have a page with different web links, now what I am trying to do is whenever a user clicks on a link that link is captured using event.target method. I'm...
6
by: Dave | last post by:
I have a situation where I want to react to a ctrl-click on a <span> and it works in Netscape and Firefox browsers but in IE I have a problem. In IE I do catch the ctrl-click but IE also renders...
1
by: Jarrod Hermer | last post by:
Hi All, I am trying to debug a strange problem of duplicate entries in my database when I came across the following errors in the event log (see bottom of mail). The web server runs the database...
6
by: D | last post by:
I have a simple file server utility that I wish to configure as a Windows service - using the examples of the Python Win32 book, I configured a class for the service, along with the main class...
4
by: bjm | last post by:
I am writing a program that will automate a series of application installations. I want to give the user the option of stopping the program's execution in between installations (for example, give...
6
by: =?Utf-8?B?VmVybm9uIFBlcHBlcnM=?= | last post by:
I have an application that is designed for using with a bar code scanner. I want the user to know that the scan was complete and the data was entered, so I am playing a system sound after data...
2
by: Steve | last post by:
Hi All, I've been trying to come up with a good way to run a certain process at a timed interval (say every 5 mins) using the SLEEP command and a semaphore flag. The basic thread loop was always...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.