IE中的ctrlKey属性 [英] ctrlKey property in IE

查看:98
本文介绍了IE中的ctrlKey属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我尝试执行以下操作,我会不断发现''会员未找到''错误

命令:

//

窗口.event.ctrlKey = false; //为属性赋值

//


是否不允许更改window.event.ctrlKey值?但

根据
http://msdn.microsoft.com/library/de...es/ctrlkey.asp

,ctrlKey属性是在IE 5及更高版本中读/写的?


有人会给我一个线索吗?有什么方法我可以''取消'

按下ctrlKey?


谢谢!

Hiroshi

I keep getting ''member not found'' error if I try to do the below
command:
//
window.event.ctrlKey = false; // assigning value to property
//

Is it not allowed to change the window.event.ctrlKey value? But
according to the reference in
http://msdn.microsoft.com/library/de...es/ctrlkey.asp
, the ctrlKey property is read/write in IE 5 and later?

Would anybody give me a clue? Is there any way that I can ''cancel'' the
pressed ctrlKey?

Thanks!
Hiroshi

推荐答案

2004年4月4日10:10:25 -0700,Hiroshi Ochi< hi ********** @ hotmail.com>

写道:
On 4 Apr 2004 10:10:25 -0700, Hiroshi Ochi <hi**********@hotmail.com>
wrote:
如果我尝试执行以下命令,我会一直收到''member not found''错误:
//
window.event.ctrlKey = false; //为属性分配值
//

是否不允许更改window.event.ctrlKey值?


我会争辩,不,你不应该......

但根据[url]中的引用,ctrlKey属性是在IE 5及更高版本中读/写?


....但正如你所说,他们确实表明它是可写的。但是,微软的

文档说很多事情都不是真的,所以不是那么令人惊讶。


我相信读/写状态仅在一种情况下才为真:

当用户使用Microsoft的

document.createEventObject创建一个事件对象时() 方法。返回的事件对象使用

默认值,因此用户必须根据需要修改信息。然后可以使用Microsoft的obj.fireEvent()方法[1]来解雇



使用预先存在的事件 - 即那些由浏览器生成 - 所有

属性都是只读的。毕竟,当事件被触发时,它们应该代表系统的

状态,因此允许作者用b $ b b改变它会破坏数据。

有人能给我一些线索吗?有什么方法可以取消按下按下的ctrlKey吗?
I keep getting ''member not found'' error if I try to do the below
command:
//
window.event.ctrlKey = false; // assigning value to property
//

Is it not allowed to change the window.event.ctrlKey value?
I would argue, no, you shouldn''t be able to...
But according to the reference in [url], the ctrlKey property is
read/write in IE 5 and later?
....but as you say, they do indicate it''s writable. However, Microsoft''s
documentation says many things that aren''t true, so it''s not that
surprising.

I believe that the read/write status is only true under one condition:
when the user creates an event object using Microsoft''s
document.createEventObject() method. The event object returned uses
default values, so the user must modify the information as appropriate. It
can then be fired with Microsoft''s obj.fireEvent() method[1].

With pre-existing events - that is, those generated by the browser - all
properties are read-only. They are, after all, supposed to represent the
state of the system when the event was fired, so allowing an author to
change that at a whim would corrupt the data.
Would anybody give me a clue? Is there any way that I can ''cancel'' the
pressed ctrlKey?




不直接。你将不得不添加某种形式的逻辑来忽略密钥。如果

这用于改变,比如说CTRL + K改为K,你可以返回一个值

代表键的字符代码,有效地覆盖了什么

用户做了。但是,我认为这只有IE支持,如果它有任何用处,我也没有测试过b $ b。你没有给出足够的信息。

希望有所帮助,

Mike

[1]我一直指的是微软的方法,因为它们不符合W3C DOM 2事件规范




-

Michael Winter
M.******@blueyonder.co.invalid(将.invalid替换为.uk以回复)



Not directly. You''ll have to add some form of logic to ignore the key. If
this is used to change, say CTRL+K to K, you can return a value that
represents the character code of the key, effectively over-riding what the
user did. However, I think this is only supported by IE, and I haven''t
tested if it will be of any use - you didn''t give enough information.

Hope that helps,
Mike
[1] I keep referring to "Microsoft''s" methods, because they do not conform
to the W3C DOM 2 Event specification.

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)


Hiroshi Ochi写道:
Hiroshi Ochi wrote:
如果我尝试执行以下
命令,我会一直收到''member not found''错误:
//
window.event.ctrlKey = false; //为属性分配值
//

是否不允许更改window.event.ctrlKey值?但
根据 http://msdn.microsoft.com/library/de...es/ctrlkey.asp
,ctrlKey属性是读/写在IE 5及更高版本中?

有人会给我一个线索吗?有什么方法可以取消按下按下的ctrlKey吗?

谢谢!
Hiroshi
I keep getting ''member not found'' error if I try to do the below
command:
//
window.event.ctrlKey = false; // assigning value to property
//

Is it not allowed to change the window.event.ctrlKey value? But
according to the reference in
http://msdn.microsoft.com/library/de...es/ctrlkey.asp
, the ctrlKey property is read/write in IE 5 and later?

Would anybody give me a clue? Is there any way that I can ''cancel'' the
pressed ctrlKey?

Thanks!
Hiroshi




让我直截了当。您网页的访问者按下< Ctrl>

键,您的javascript函数将在MSIE中中止它...或者这个

就是您想要在MSIE中发生的事情。我做对了吗?

你能解释一下你的网页背景,情况,要求吗?它的网址是什么?$ / b

DU



Let me get this straight. The visitor of your webpage presses the <Ctrl>
key and your javascript function will neutralize it in MSIE... or this
is what you want to happen in MSIE. Did I get this right?
Can you explain your webpage context, situation, requirements? What''s
its url?

DU


感谢Michael和DU,


为了增强可用性,我想设置TAB行为如果用户

按CTRL +右箭头键并设置SHIFT + TAB行为如果

用户按CTRL +左箭头键。


我特别需要在HTML表格中使用此功能。目前,我只需要专注于与MSIE ver.6.0及更高版本的兼容性。


以下是我想要实现的代码。


//

如果(!window.event.ctrlKey)返回true;

尝试{

switch(window.event.keyCode){

case 37:// left

window.event.keyCode = 9;

window。 event.ctrlKey = false; //< - 这是问题

休息;

案例39://正确

window.event.keyCode = 9;

window.event.ctrlKey = false; //< - 这是问题

window.event.shiftKey = true; //< - 这也是问题..

休息;

}

返回true;

}

catch(例外)

{

返回false;

}


先谢谢了!


rgs,

hiroshi


***通过开发人员指南 http://www.developersdex.com 发送***

不要只是参加USENET ......获得奖励!
Thanks Michael and DU,

To enhanced usability, I would like to set the TAB behaviour if user
presses ''CTRL + Right Arrow'' key and to set the SHIFT + TAB behaviour if
user presses ''CTRL + Left Arrow'' key.

I especially need this function in HTML Tables. For the time being, I
can only concentrate for compatibility with MSIE ver.6.0 and above.

Below is the code that I want to implement.

//
if (!window.event.ctrlKey) return true;
try {
switch(window.event.keyCode){
case 37: // left
window.event.keyCode = 9;
window.event.ctrlKey = false; // <-- this is the problem
break;
case 39: // right
window.event.keyCode = 9;
window.event.ctrlKey = false; // <-- this is the problem
window.event.shiftKey = true; // <-- this is also problem..
break;
}
return true;
}
catch(exception )
{
return false;
}

Thanks in advanced!

rgs,
hiroshi


*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!


这篇关于IE中的ctrlKey属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆