禁用 IE 6 中的特定键

发布于 2024-07-05 05:56:03 字数 433 浏览 8 评论 0原文

我需要禁用 Internet Explorer 6 中的特定键(Ctrl 和 Backspace)。是否有注册表黑客可以执行此操作。 必须是IE6。 谢谢。

长编辑:

@apandit:哎呀。 我需要更具体地了解退格键的事情。 当我说禁用退格键时,我的意思是禁用退格键模仿后退浏览器按钮的功能。 在 IE 中,当焦点不在文本输入字段中时按 Backspace 相当于按 Back(浏览到上一页)。

至于Ctrl键。 有些页面包含创建新 IE 窗口的链接。 我打开了弹出窗口阻止程序,可以阻止此操作。 但是,按住 Ctrl 键单击会启动新窗口。

这是一个信息亭应用程序,目前是一个基于 Web 的应用程序。 客户目前没有资金来使他们的网站信息亭变得友好。 URL 过滤和禁用 URL 输入字段等操作已经完成。

谢谢。

I need to disable specific keys (Ctrl and Backspace) in Internet Explorer 6. Is there a registry hack to do this. It has to be IE6. Thanks.

Long Edit:

@apandit: Whoops. I need to more specific about the backspace thing. When I say disable backspace, I mean disable the ability for Backspace to mimic the Back browser button. In IE, pressing Backspace when the focus is not in a text entry field is equivalent to pressing Back (browsing to the previous page).

As for the Ctrl key. There are some pages which have links which create new IE windows. I have the popup blocker turned on, which block this. But, Ctrl clicking result in the new window being launched.

This is for a kiosk application, which is currently a web based application. Clients do not have the funds at this time to make their site kiosk friendly. Things like URL filtering and disabling the URL entry field is already done.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

ˇ宁静的妩媚 2024-07-12 05:56:04

我正在使用这个 jQuery 解决方案(在 ie6 和 firefox 3.6 上测试):

$(document).keydown(function(e) {
    var tag = e.target.tagName;
    var ro = e.target.readOnly;
    var type = e.target.type;
    var tags = {
        INPUT : '',
        TEXTAREA : ''
    };
    if (e.keyCode == 8) {// backspace
        if (!(tag in tags && !ro && /text/.test(type))) {
            e.stopPropagation();
            e.preventDefault();
        }
    }
});    

希望它对某人有帮助

I'm using this jQuery solution (tested on ie6 and firefox 3.6):

$(document).keydown(function(e) {
    var tag = e.target.tagName;
    var ro = e.target.readOnly;
    var type = e.target.type;
    var tags = {
        INPUT : '',
        TEXTAREA : ''
    };
    if (e.keyCode == 8) {// backspace
        if (!(tag in tags && !ro && /text/.test(type))) {
            e.stopPropagation();
            e.preventDefault();
        }
    }
});    

hope it helps someone

瀟灑尐姊 2024-07-12 05:56:03

您无法从网页执行此操作。 网络浏览器的主要目的之一是保护用户免受互联网侵害。 它们定义了网站可以执行的一组非常具体的操作,并且禁用按钮不在列表中。

另一方面,如果您是网络管理员并且只是想扰乱您的用户,您也许可以通过某些桌面软件来做到这一点。 但我不会屏住呼吸。

You can't do it from a web page. One of the main purposes of a web browser is to protect users from the internet. They define a very specific set of things that web sites can do, and disabling buttons isn't in the list.

On the other hand, if you're a network admin and just want to mess with your users, you might be able to do it via some desktop software. But I wouldn't hold my breath.

权谋诡计 2024-07-12 05:56:03

您需要这个的目的是什么? 因为禁用退格键对于输入网址或电子邮件等来说会很糟糕。

如果我们更好地了解问题,我们可以推荐其他解决方法。

编辑1:
该网站似乎有一些有关如何完成的信息。 我目前无法验证,但我会调查一下:
http://www.ozzu.com/programming- forum/disable-key-and-back-t44867.html

编辑 2:
该网站有一些关键代码:
http://www.advscheduler.com/docs/manual/type_sendkeys.html
退格键似乎是 08。

编辑 3:
找到了更多用于阻止的代码,请查看:

<script type="text/javascript">var sType = "keypress";</script> 

<!--[if IE]> 
<script type="text/javascript">sType = "keydown";</script> 
<![endif]--> 

<script type="text/javascript"> 
fIntercept = function(e) { 
   // alert(e.keyCode);
  e = e || event.e; 
  if (e.keyCode == 116) { 
   // When F5 is pressed 
   fCancel(e); 
  } else if (e.ctrlKey && (e.keyCode == 0 || e.keyCode == 82)) { 
   // When ctrl is pressed with R 
   fCancel(e); 
  } 
}; 

fCancel = function(e) { 
  if (e.preventDefault) { 
   e.stopPropagation(); 
   e.preventDefault(); 
  } else { 
   e.keyCode = 0; 
   e.returnValue = false; 
   e.cancelBubble = true; 
  } 
  return false; 
}; 

fAddEvent = function(obj, type, fn) { 
  if (obj.addEventListener) { 
   obj.addEventListener(type, fn, false); 
  } else { 
   obj['e'+type+fn] = fn; 
   obj[type+fn] = function() { 
    obj['e'+type+fn](window.event); 
   } 
   obj.attachEvent('on'+type, obj[type+fn]); 
  } 
}; 


fAddEvent(document, sType, fIntercept); 
</script> 

好的,现在您应该拥有执行此操作所需的所有内容。 要禁用退格键,键码是 08。您可能只需使用我发布的代码,稍加修改即可...:\

尝试一下,看看它是否是您所需要的。 (我希望你知道如何使用Javascript。)

For what purpose do you need this? Because disabling the backspace would be hell for typing urls or emails, etc.

We could recommend other workarounds if we knew the problem better.

EDIT 1:
This website seems to have some information as to how it's done. I can't verify it currently, but I'll look into it:
http://www.ozzu.com/programming-forum/disable-key-and-back-t44867.html

Edit 2:
This website has some key codes:
http://www.advscheduler.com/docs/manual/type_sendkeys.html
It seems BACKSPACE is 08.

EDIT 3:
Found some more code for blocking, check this out:

<script type="text/javascript">var sType = "keypress";</script> 

<!--[if IE]> 
<script type="text/javascript">sType = "keydown";</script> 
<![endif]--> 

<script type="text/javascript"> 
fIntercept = function(e) { 
   // alert(e.keyCode);
  e = e || event.e; 
  if (e.keyCode == 116) { 
   // When F5 is pressed 
   fCancel(e); 
  } else if (e.ctrlKey && (e.keyCode == 0 || e.keyCode == 82)) { 
   // When ctrl is pressed with R 
   fCancel(e); 
  } 
}; 

fCancel = function(e) { 
  if (e.preventDefault) { 
   e.stopPropagation(); 
   e.preventDefault(); 
  } else { 
   e.keyCode = 0; 
   e.returnValue = false; 
   e.cancelBubble = true; 
  } 
  return false; 
}; 

fAddEvent = function(obj, type, fn) { 
  if (obj.addEventListener) { 
   obj.addEventListener(type, fn, false); 
  } else { 
   obj['e'+type+fn] = fn; 
   obj[type+fn] = function() { 
    obj['e'+type+fn](window.event); 
   } 
   obj.attachEvent('on'+type, obj[type+fn]); 
  } 
}; 


fAddEvent(document, sType, fIntercept); 
</script> 

Ok, now you should have all you need to do it. To disable backspace, the keycode is 08. You can probably just use the code I posted with slight modifications only... :\

Try it out and see if it's what you needed. (I hope you know how to use Javascript.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文