什么是[对象窗口]?

mrd*_*iri 4 javascript

谷歌翻译,有一些书签允许翻译,点击一下,例如:

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;};
Run Code Online (Sandbox Code Playgroud)

这个javascript代码打开当前页面中的翻译页面(target = _self),但是我希望它打开一个新窗口(tab)进行翻译.所以改为:

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);};
Run Code Online (Sandbox Code Playgroud)

我的问题在于:当我运行该代码时,它会为翻译打开一个新窗口,然后执行此操作; 但非英文页面内容被替换[object Window],但我不想改变原始页面内容......

我能做什么?

谢谢 ..

Mat*_*hen 9

最后添加void(0),所以没有价值.如果最后一个表达式具有值(在本例中为窗口),则将页面替换为该页面.