阅读:2803回复:7
求助:关于站内搜索的问题
我砍到有个帖子说是把这段代码制作成书签就可以站内搜索
javascript:q%20=%20%22%22%20+%20(window.getSelection%20?%20window.getSelection()%20:%20document.getSelection%20?%20document.getSelection()%20:%20document.selection.createRange().text);%20if%20(!q)%20q%20=%20prompt(%22You%20didn't%20select%20any%20text.%20%20Enter%20a%20search%20phrase:%22,%20%22%22);%20if%20(q!=null)%20location=(%22http://www.google.com/search?num=100&q=site:%22%20+%20escape(location.hostname)%20+%20%22%20\%22%22%20+%20q.replace(/\%22/g,%22%22)%20+%20%22\%22%22).replace(/%20/g,%20%22+%22);%20void%200 但是搜索的时候是在当前标签页中打开,能不能在新建标签页中打开 |
|
1楼#
发布于:2010-06-09 19:55
javascript:q%20=%20%22%22%20+%20(window.getSelection%20?%20window.getSelection()%20:%20document.getSelection%20?%20document.getSelection()%20:%20document.selection.createRange().text);%20if%20(!q)%20q%20=%20prompt(%22%E8%AF%B7%E8%BE%93%E5%85%A5%E5%85%B3%E9%94%AE%E8%AF%8D:%22,%20%22%22);%20if%20(q!=null)%20{var%20qlocation=%22%20%22;qlocation=(%22http://www.google.com/search?num=100&hl=en-US&newwindow=1&q=site:%22%20+%20escape(location.hostname)+%22+%22+q+%22%22);window.open(qlocation);}%20void%200 |
|
|
2楼#
发布于:2010-06-09 19:55
感谢楼上.高人啊
|
|
3楼#
发布于:2010-06-09 19:55
kmc:javascript:q%20=%20%22%22%20+%20(window.getSelection%20?%20window.getSelection()%20:%20document.getSelection%20?%20document.getSelection()%20:%20document.selection.createRange().text);%20if%20(!q)%20q%20=%20prompt(%22%E8%AF%B7%E8%BE%93%E5%85%A5%E5%85%B3%E9%94%AE%E8%AF%8D:%22,%20%22%22);%20if%20(q!=null)%20{var%20qlocation=%22%20%22;qlocation=(%22http://www.google.com/search?num=100&hl=en-US&newwindow=1&q=site:%22%20+%20escape(location.hostname)+%22+%22+q+%22%22);window.open(qlocation);}%20void%200回到原帖 这个代码搜索汉字的话会乱码,怎么样修改啊? |
|
4楼#
发布于:2010-06-09 19:55
用这个试试
javascript:q%20=%20%22%22%20+%20(window.getSelection%20?%20window.getSelection()%20:%20document.getSelection%20?%20document.getSelection()%20:%20document.selection.createRange().text);%20if%20(!q)%20q%20=%20prompt(%22%E8%AF%B7%E8%BE%93%E5%85%A5%E5%85%B3%E9%94%AE%E8%AF%8D:%22,%20%22%22);%20if%20(q!=null)%20{var%20qlocation=%22%20%22;qlocation=('http://www.google.com/search?num=100&hl=zh-CN&newwindow=1&q='+q+'&sitesearch='+location.host+'');window.open(qlocation);}%20void%200 百度站内搜 javascript:var%20Bar=location.host+"";q%20=%20%22%22%20+%20(window.getSelection%20?%20window.getSelection()%20:%20document.getSelection%20?%20document.getSelection()%20:%20document.selection.createRange().text);%20if%20(!q)%20q%20=%20prompt(%22\u8BF7\u8F93\u5165\u641C\u7D22\u7684\u5173\u952E\u8BCD:%22,%20%22%22);%20if%20(q!=null)%20{var%20qlocation=%22%20%22;qlocation=('http://www.baidu.com/s?&ie=UTF-8&oe=UTF-8&cl=3&rn=100&wd=%20%20'+q+'%20%20%20site:%20'+Bar+'');window.open(qlocation);}%20void%200 这两个在火狐中基本正常 |
|
5楼#
发布于:2010-06-09 19:55
我那段代码我自己搜索中文是正常的
|
|
|
6楼#
发布于:2010-06-09 19:55
|
|
7楼#
发布于:2010-06-09 19:55
enterhu:用这个试试javascript:q%20=%20%22%22%20+%20(window.getSelection%20?%20window.getSelection()%20:%20document.getSelection%20?%20document.getSelection()%20:%20document.selection.createRange().text);%20if%20(!q)%20q%20=%20prompt(%22%E8%AF%B7%E8%BE%93%E5%85%A5%E5%85%B3%E9%94%AE%E8%AF%8D:%22,%20%22%22);%20if%20(q!=null)%20{var%20qlocation=%22%20%22;qlocation=('http://www.google.com/search?num=100&hl=zh-CN&newwindow=1&q='+q+'&sitesearch='+location.host+'');window.open(qlocation);}%20void%200 感谢.这个的google站内搜索解决问题了 |
|