简体   繁体   English

如何防止 Firefox 的站内搜索弹出?

[英]How to prevent Firefox' in-site-search from popping up?

My problem is, is that the numpad's "/" key triggers the search bar in Firefox.我的问题是,小键盘的“/”键会触发 Firefox 中的搜索栏。 I would like to prevent this from happening.我想防止这种情况发生。

I'm currently working on an online Calculator, and ran into the problem described earlier.我目前正在开发一个在线计算器,并遇到了前面描述的问题。 The reason why I would like this not to happen, is because you obviousely can't type in a division thanks to this feature.我不希望这种情况发生的原因是,由于此功能,您显然无法输入除法。 The page is only meant to run in Firefox, and it's just a little help for my little brother, so it doesnÄt have to be the most professional solution - if it works, it's fine.该页面仅用于在Firefox中运行,对我的小兄弟有一点帮助,所以它不一定是最专业的解决方案——如果它可以工作,那就没问题了。 I've already tried the preventDefault method, but that doesn't change anything.我已经尝试过 preventDefault 方法,但这并没有改变任何东西。

Any help is appreciated!任何帮助表示赞赏!

(Sorry if this question was already asked before, or it doesn't append to the rules, I'm totally new to StackOverflow) (对不起,如果这个问题之前已经被问过,或者它不符合规则,我对 StackOverflow 完全陌生)

window.addEventListener("keyup", function (event) {
    let signs = ["*", "-", "/", "+"];

    event.key.preventDefault;

    if (!(isNaN(event.key)) || signs.includes(event.key)) output.value += event.key;

    else if (event.keyCode === 8) {
      output.value = output.value.slice(0, -1);
    }
  })

//This is a snippet of my code right now, but the event.key.preventDefault part doesn't work for my problem

I think you should use preventDefault like this:我认为你应该像这样使用 preventDefault :

event.preventDefault();

I don't know whether this will block the search box or not, but you can call preventDefault like this.我不知道这是否会阻止搜索框,但是您可以像这样调用 preventDefault 。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 防止Firefox自动完成弹出 - Prevent Firefox autocompletion from popping up 如何防止野生动物园弹出密码保存框? - How to prevent safari from popping up a password saving box? 如何防止键盘在移动设备上弹出? - How to prevent the keyboard from popping up on mobile devices? 防止键盘在 datepicker mobile 上弹出 - prevent keyboard from popping up on datepicker mobile 如何在 Firefox 中使用 html/javascript 禁用斜杠和撇号键弹出快速查找? - How do I disable the slash and apostrophe keys from popping up quick find in Firefox with html/javascript? 如何取消/阻止PayPal的结帐模式在满足条件之前弹出? - How to cancel / prevent PayPal's checkout modal from popping up before a condition is met? 提交联系表格后如何防止PHP文件弹出? - How do I prevent PHP file from popping up after submitting contact form? 如何防止 jQuery datepicker 在初始页面加载时弹出但仍滚动到 datepicker 文本框 - How to prevent jQuery datepicker from popping up on initial page load but still scroll to datepicker textbox 防止在休假时弹出“确认导航”对话框 - Prevent the “Confirm Navigation” dialog box from popping up on page leave 如何防止网站显示退出确认信息(该网站是在您的网站弹出窗口中打开的)? - How to prevent a site to show exit confirmation (the site is opened in a pop up from your site)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM