谷歌翻译有一些书签可以让您一键翻译,例如:
javascript:var t=((window.getSelection&&window.getSelection())||(document.getSelection&&document.getSelection())||(document.selection&&document.selection.createRange&&document.selection.createRange().text));var e=(document.charset||document.characterSet);if(t!=''){location.href='http://translate.google.com/?text='+t+'&hl=en&langpair=auto|en&tbb=1&ie='+e;}else{location.href='http://translate.google.com/translate?u='+encodeURIComponent(location.href)+'&hl=en&langpair=auto|en&tbb=1&ie='+e;};
此 JavaScript 代码在当前页面(target=_self)中打开翻译器页面,但我希望它打开一个新窗口(选项卡)进行翻译。所以改为:
javascript:var t=((window.getSelection&&window.getSelection())||(document.getSelection&&document.getSelection())||(document.selection&&document.selection.createRange&&document.selection.createRange().text));var e=(document.charset||document.characterSet);if(t!=''){window.open('http://translate.google.com/?text='+t+'&hl=en&langpair=auto|en&tbb=1&ie='+e);}else{window.open('http://translate.google.com/translate?u='+encodeURIComponent(location.href)+'&hl=en&langpair=auto|en&tbb=1&ie='+e);};
我的问题在于:当我运行该代码时,它会打开一个新窗口进行翻译,然后执行该操作;但非英文页面内容替换为[object Window]
,但我不想更改原始页面内容...
我能做些什么?
谢谢 ..
Add void(0)
最后,所以不会有任何价值。如果最后一个表达式有一个值(在本例中是一个窗口),则页面将被替换为该值。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)