hi all,
we have a requirement to disable shift click and ctrl click.
i have code: - document.onmousedown = shiftEnter;
-
-
function shiftEnter(e) {
-
if (event.shiftKey) {
-
alert("shift key is disabled");
-
return false;
-
}
-
}
-
this code is not working in Fire fox, please help.
thanks,
rakesh.
9 10258 acoder 16,027
Recognized Expert Moderator MVP
Please enclose your posted code in [code] tags (See How to Ask a Question).
This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.
Please use [code] tags in future.
Moderator.
acoder 16,027
Recognized Expert Moderator MVP
Browsers besides IE would use the 'e' while IE uses the global window.event.
For a cross-browser solution, use something like: - if (!e) var e = window.event;
then e will refer to the event.
Browsers besides IE would use the 'e' while IE uses the global window.event.
For a cross-browser solution, use something like: - if (!e) var e = window.event;
then e will refer to the event.
Thanks for quick reply but It doesnt worked, can you suggest some other way of handling this, detecting event.shiftKey/event.ctrlKey events in Fire Fox.
acoder 16,027
Recognized Expert Moderator MVP
Thanks for quick reply but It doesnt worked, can you suggest some other way of handling this, detecting event.shiftKey/event.ctrlKey events in Fire Fox.
What does your code look like now?
What does your code look like now?
-
function shiftEnter(e) {
-
if(navigator.userAgent.indexOf("MSIE") >= 0) {
-
if ( event.shiftKey || event.ctrlKey ) {
-
alert("MSIE");
-
var msg = "<bean:message key='home.player.operationNotAllowed' />";
-
alert(msg);
-
return false;
-
}
-
} else if(navigator.userAgent.indexOf("Firefox") >= 0) {
-
if(!e){
-
alert("Fire fox");
-
var e = window.event;
-
if( e.shifyKey || e.ctrlKey ){
-
var msg = "<bean:message key='home.player.operationNotAllowed' />";
-
alert(msg);
-
return false;
-
}
-
}
-
}
-
}
-
My code looks like this, please inform if anything wrong.
acoder 16,027
Recognized Expert Moderator MVP
Yes, there's no need for browser detection. Try this: - function shiftEnter(e) {
-
if (!e) var e = window.event;
-
if (e.shiftKey || e.ctrlKey ) {
-
var msg = "<bean:message key='home.player.operationNotAllowed' />";
-
alert(msg);
-
return false;
-
}
-
}
Yes, there's no need for browser detection. Try this: - function shiftEnter(e) {
-
if (!e) var e = window.event;
-
if (e.shiftKey || e.ctrlKey ) {
-
var msg = "<bean:message key='home.player.operationNotAllowed' />";
-
alert(msg);
-
return false;
-
}
-
}
Sorry it is not working :( , is there any other different way to solve this problem.
hi the following code worked nicely for me both in ie and firefox... - <script language=javascript>
-
document.onmousedown = shiftEnter;
-
function shiftEnter(e) {
-
if (!e) var e = window.event;
-
if (e.shiftKey || e.ctrlKey ) {
-
var msg = "<bean:message key='home.player.operationNotAllowed' />";
-
alert(msg);
-
return false;
-
}
-
}
-
</script>
there is no reason the code shouldn't work for u..
do u get any errors or warnings??
if s please post the error or warning u r getting..
acoder 16,027
Recognized Expert Moderator MVP
It works for me in Firefox. Can you post the rest of your code (if it's not too much). Maybe something else is affecting the script.
Edit: Thanks kvijayhari. You posted before I managed to finish typing.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Matthew |
last post by:
Is there anyway to tweak this to ignore the function() only if the Tab
key is pressed?
onkeydown="javascript:function();"
|
by: datactrl |
last post by:
Hi, all
Is that possible to fire a "tab" key press event with javascript?
jack
|
by: znndrp |
last post by:
Hi all,
I've got a function that captures a keypress event. This is working fine,
but in some cases I want to fire the same even again but with different
parameters.
Example;
----------------8<------------------------------------------
function editor_event(objname,runDelay) {
|
by: jhcorey |
last post by:
Right now I have code like this which works in IE (this fires on an
onclick):
function f_Click(x)
{
if (window.event.shiftKey)
{
I'd like to find the simplest way to make this work cross-browser. In
|
by: moondaddy |
last post by:
I have a <a> element in a datagrid which wraps some asp.net labels. this
element also has an onclick event which does not fire in netscape 6 (and
perhaps other browsers for all I know...). Below is the code for this. the
onclick event calls a javascript function which I put an alert in the firt
line to tell me if its working. It does work in IE. Any ideas on how to
get netcrap... oops, I'm sorry, netscape to fire the onclick event?
...
| |
by: lechatthierry |
last post by:
Is it possible to block a mouse event on an Hyperlink with a general
script event?
This is quite troublesome for me. I am trying to find a way to block
the windows shortcut SHIFT + MOUSE LEFT BUTTON that open the Hyperlink
in a new window for a Web application. I just want to capture the Shift
click event and prevent it from opening a new page.
Mouse Wheel didn't pose any problems but the other mouse buttons seems
to ignore the...
|
by: Neko |
last post by:
Is it possible to block a mouse event on an Hyperlink with a general
script event?
This is quite troublesome for me. I am trying to find a way to block
the windows shortcut SHIFT + MOUSE LEFT BUTTON that open the Hyperlink
in a new window for a Web application. I just want to capture the Shift
click event and prevent it from opening a new page.
Mouse Wheel didn't pose any problems but the other mouse buttons seems
to ignore the...
|
by: mingchin.AT |
last post by:
Hi,
In Javascript, the simple way to check user input is to get the keycode.
But for cross browser, its seems we need to have two different keycodes
for the same key.
There is a web page for get keycode vs event types.
http://www.w3.org/2002/09/tests/keys-cancel2.html
|
by: hui11 |
last post by:
Hi,
According to the doc at mozilla, http://developer.mozilla.org/en/docs/DOM:event.charCode, the charCode takes shift into consideration when pressed. I found that to be true for other cases except when Alt+Shift is pressed. For example, the charCode alt+shift+a does not reflect a capitalized a, 'A', or alt+shift+1 does not reflect '!', instead they should 'a' and '1', respectively. Furthermore, I found that when alt+shift is pressed, the...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |