简体   繁体   English

覆盖浏览器的CTRL + F并将其替换为Silverlight自定义搜索

[英]overriding the browser's CTRL+F and replace it with Silverlight custom search

Can anyone help me in Overriding the browser's CTRL+F and replace it with Silverlight Custom-search. 任何人都可以帮助我覆盖浏览器的CTRL + F并将其替换为Silverlight自定义搜索。 I guess we can have JavaScript to handle this case. 我想我们可以使用JavaScript来处理这种情况。

You can try this, to replace the Find function: 您可以尝试这个,以替换查找功能:

window.addEventListener("keypress",function (event) { /* Add keydown too */
    if ((event.keyCode == 114) || (event.ctrlKey && event.keyCode == 70)) { 
    // Block CTRL + F event
        event.preventDefault();
    }
})

I have made a keyboard shortcut for this on my website, i have also created this JSFiddle With the script on it and a working demo below this post! 我已经在我的网站上为此创建了一个键盘快捷键,我也创建了这个JSFiddle上面的脚本和这个帖子下面的工作演示! The demo is the exact same as in the fiddle! 演示与小提琴完全相同! Also For reference the source for my site url as seen in snippet is This Link And My other stack overflow post, very different from this one by the way, is this URL And the shortcut.js fiddle is this one 另外作为参考,我的网站url的源代码在片段中看到的是这个链接和我的其他堆栈溢出帖子,顺便说一下, 这个URL这个URL和shortcut.js小提琴就是这个

 <h1> Click In This Box and press ctrl+F </h1> <a href https://antimalwareprogram.co/view-source:antimalwareprogram.co-pages_php.source-javascript_page.js tagret=blank>Click to see my site source if this fiddle is broken!</a> <p> <b></b>This is The Url: https://antimalwareprogram.co/view-source:antimalwareprogram.co-pages_php.source-javascript_page.js<b></b></p> <h1> Then Scroll down to the bottom then scroll up, or do ctrl+F there and inser this line: https://antimalwareprogram.co/shortcuts.js<h1> <h4> that and everything below it is part of my keyboard shortcuts</h4> <h1> The entire code is on the js panel</h1> <hr> <--The Javascript--> <script src="https://antimalwareprogram.co/shortcuts.js"> </script> <!-- Or Just open that script page and ctrl+A Then Ctrl+C and past it into your own site and change url to /filename.js -must save it as a .js extension! This script searches my site! To make it search your just change down below where it says --- document.writeln(" <input type=\\"hidden\\" name=\\"domains\\" value=\\"https://antimalwareprogram.co\\" checked=\\"checked\\"> "); document.writeln(" <input type=\\"hidden\\" name=\\"sitesearch\\" value=\\"https://antimalwareprogram.co\\" checked=\\"checked\\"> "); Just change the https://antimalwareprogram.co on both lines to https://yoursite or http://yoursite make sure not to remove the other slashes around it though or the script wont work, also this wont work if you have a script blocker blocker , so you can have a html meta no script redirect tag but nothing else will work if its not that meta tag for noscript! --> <script> shortcut.add("Ctrl+F",function() { document.writeln(" <link href=\\"https://docs.google.com/static/document/client/css/3164405079-KixCss_ltr.css\\" type=\\"text/css\\" rel=\\"stylesheet\\"> "); document.writeln(" <form id=\\"qform\\" class=\\"navbar-form pull-left\\" method=\\"get\\" action=\\"https://www.google.com/search\\" role=\\"search\\"> "); document.writeln(" "); document.writeln(" "); document.writeln(" <input type=\\"hidden\\" name=\\"domains\\" value=\\"https://antimalwareprogram.co\\" checked=\\"checked\\"> "); document.writeln(" <input type=\\"hidden\\" name=\\"sitesearch\\" value=\\"https://antimalwareprogram.co\\" checked=\\"checked\\"> "); document.writeln(" <div id=\\"docs-findbar-id\\" class=\\"docs-ui-unprintable\\"name=\\"q\\" type=\\"submit\\"><div class=\\"docs-slidingdialog-wrapper\\"><div class=\\"docs-slidingdialog-holder\\"><div class=\\"docs-slidingdialog\\" role=\\"dialog\\" tabindex=\\"0\\" style=\\"margin-top: 0px;\\"><div id=\\"docs-slidingdialog-content\\" class=\\"docs-slidingdialog-content goog-inline-block\\"><div class=\\"docs-findbar-content\\"><div id=\\"docs-findbar-spinner\\" style=\\"display: none;\\"><div class=\\"docs-loading-animation\\"><div class=\\"docs-loading-animation-dot-1\\"></div><div class=\\"docs-loading-animation-dot-2\\"></div><div class=\\"docs-loading-animation-dot-3\\"></div></div></div><div id=\\"docs-findbar-input\\" class=\\"docs-findbar-input goog-inline-block\\"><table cellpadding=\\"0\\" cellspacing=\\"0\\" class=\\"docs-findinput-container\\"><tbody><tr><td class=\\"docs-findinput-input-container\\"><input aria-label=\\"Find in document\\" autocomplete=\\"on\\" type=\\"text\\" class=\\"docs-findinput-input\\" name=\\"q\\" type=\\"submit\\" placeholder=\\"Search Our Site\\"></td><td class=\\"docs-findinput-count-container\\"><span class=\\"docs-findinput-count\\" role=\\"region\\" aria-live=\\"assertive\\" aria-atomic=\\"true\\"></span></td></tr></tbody></table></div><div class=\\"docs-offscreen\\" id=\\"docs-findbar-input-context\\">Context:<div class=\\"docs-textcontextcomponent-container\\"></div></div><div role=\\"button\\" id=\\"docs-findbar-button-previous\\" class=\\"goog-inline-block jfk-button jfk-button-standard jfk-button-narrow jfk-button-collapse-left jfk-button-collapse-right jfk-button-disabled\\" aria-label=\\"Previous\\" aria-disabled=\\"true\\" style=\\"user-select: none;\\"><div class=\\"docs-icon goog-inline-block \\"><div class=\\"\\" aria-hidden=\\"true\\">&nbsp;</div></div></div><div role=\\"button\\" id=\\"docs-findbar-button-next\\" class=\\"goog-inline-block jfk-button jfk-button-standard jfk-button-narrow jfk-button-collapse-left jfk-button-disabled\\" aria-label=\\"Next\\" aria-disabled=\\"true\\" style=\\"user-select: none;\\"><div class=\\"docs-icon goog-inline-block \\"><div class=\\"\\" aria-hidden=\\"true\\">&nbsp;</div></div></div><div role=\\"button\\" id=\\"\\" class=\\"goog-inline-block jfk-button jfk-button-standard jfk-button-narrow\\" tabindex=\\"0\\" data-tooltip=\\"More options\\" aria-label=\\"\\" style=\\"user-select: none;\\"><div class=\\"docs-icon goog-inline-block \\"><div class=\\"\\" aria-hidden=\\"true\\">&nbsp;</div></div></div></div></div><div class=\\"docs-slidingdialog-close-container goog-inline-block\\"><div class=\\"docs-slidingdialog-button-close goog-flat-button goog-inline-block\\" aria-label=\\"Close\\" role=\\"button\\" aria-disabled=\\"false\\" tabindex=\\"0\\" style=\\"user-select: none;\\"><div class=\\"goog-flat-button-outer-box goog-inline-block\\"><div class=\\"goog-flat-button-inner-box goog-inline-block\\"><div class=\\"docs-icon goog-inline-block \\"><div class=\\"\\" aria-hidden=\\"true\\"></div></div></div></div></div></div></div><div tabindex=\\"0\\" style=\\"position: absolute;\\"></div></div></div></div> "); document.writeln(" <a href=\\"#\\" onClick=\\"window.location.reload();return false;\\"></a> "); document.writeln(" "); document.writeln(" </form> "); document.writeln(" "); document.writeln(" <h1> Press esc key to cancel searching!</h1> "); shortcut.add("Ctrl+F",function() { alert("Already Searching! Press the esc key to stop searching!"); }); shortcut.add("esc",function() { location.reload(); }); }); </script> 

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM