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 10230
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.
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.
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.
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..
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;
...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |