CentBrowser Forum

Full Version: 右键菜单加一项:调用百度(或指定搜索引擎)进行站内搜索“xxx”[已解决]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
【已解决】详见4#和6#。


右键菜单加一项:调用百度(或指定搜索引擎)进行站内搜索“xxx”。
如图:
[attachment=435]
感谢反馈,会考虑你的建议。
(06-26-2017, 09:34 AM)CentBrowser Wrote: [ -> ]感谢反馈,会考虑你的建议。

Heart 十分感谢!辛苦了!

感谢楼下JS技巧,原来IE这招,chrome下面还可以用,谢谢提示。这样用也蛮有意思。
JS书签只需一步:

javascript:var ax=prompt('Google 站内搜索','');if(ax.length>0){window.open('https://www.google.com/search?&q=site:'+encodeURIComponent(location.hostname)+' '+encodeURIComponent(ax))};void(0)

必应:https://www.bing.com/search?&q=site:
搜狗:https://www.sogou.com/web?query=site:
百度:https://www.baidu.com/s?&wd=site:
感谢楼上的分享!
(06-27-2017, 01:49 AM)Doller Wrote: [ -> ]JS书签只需一步:

javascript:var ax=prompt('Google 站内搜索','');if(ax.length>0){window.open('https://www.google.com/search?&q=site:'+encodeURIComponent(location.hostname)+' '+encodeURIComponent(ax))};void(0)

必应:https://www.bing.com/search?&q=site:
搜狗:https://www.sogou.com/web?query=site:
百度:https://www.baidu.com/s?&wd=site:

Biggrin Rolleyes
非常赞~ 


我改良了一下,这下,只要选中文本,接着点这个已经保存好的书签,就可以直接调用百度进行站内搜索了。

弹窗确认版(所选文本自动放入确认对话框):

Quote:javascript:var txtS=document.getSelection().toString();var ax=prompt('用百度进行站内搜索',txtS);if(ax.length>0){window.open('https://www.baidu.com/s?&wd=site:'+encodeURIComponent(location.hostname)+' '+encodeURIComponent(ax))};void(0);


直接搜索版(不需要确认过程):


Quote:javascript:var txtS=document.getSelection().toString();if(txtS.length>0){window.open('https://www.baidu.com/s?&wd=site:'+encodeURIComponent(location.hostname)+' '+encodeURIComponent(txtS))};void(0);

如果有选择单号就直接搜索,没有则需要输入(弹出窗口确认):
Quote:javascript:function searchSite(txtS) {window.open('https://www.baidu.com/s?&wd=site:'+encodeURIComponent(location.hostname)+' '+encodeURIComponent(txtS))};var txtS=document.getSelection().toString();if(txtS.length>0){searchSite(txtS)}else{var inputS=prompt('调用百度进行站内搜索','');searchSite(inputS)};void(0);


那么@CentBrowser 不用辛苦加代码了 Exclamation
没想到几行js就能搞定了,感谢两位高手 Biggrin