2012-02-06 64 views
2

任何人都可以帮助我重写浏览器的CTRL + F并将其替换为Silverlight自定义搜索。我想我们可以用JavaScript来处理这种情况。覆盖浏览器的CTRL + F并将其替换为Silverlight自定义搜索

+0

1.确保在浏览器中捕捉到ctrl-F的“事件”。 2.调用你的Silverlight脚本。 3.在Silverlight中搜索。你可以在去这里之前做一些工作。 (当你陷入困境时,你可以要求我们帮助你,要求我们做你的工作是完全不同的事情。) – Jasper 2012-02-06 11:23:21

+1

我不认为他让我们为他做这件事,“帮助我做X“可以轻松地表示”告诉我从哪里开始“。您的评论也没有解释_how_捕获浏览器中的CTRL + F事件,这是我从谷歌来的。无助:( – 2012-05-26 18:33:55

+0

)您可以检查其他来源的代码,例如codepen.io,并将其添加到键盘覆盖事件中,就像我在下面的回答中一样! – antimalwareprogram 2017-08-15 02:21:36

回答

0

你可以试试这个,以取代查找功能:

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

我已经做了键盘快捷键这在我的网站,我也创建了这个JSFiddle与它的脚本和演示下文一个工作这个帖子!演示与小提琴完全相同!也可对照所看到的片断为我的网站的网址来源是This Link 我还有一个堆栈溢出后,从这个的方式很不同,是this URL而shortcut.js小提琴是this one

<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(" \t \t \t \t <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() { 
 
\t 
 

 

 
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(" \t \t \t \t <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() { 
 
\t alert("Already Searching! Press the esc key to stop searching!"); 
 
}); 
 
    shortcut.add("esc",function() { 
 

 
    location.reload(); 
 

 
    
 
}); 
 

 
}); 
 
</script>