什么是[对象窗口]? [英] what is the [object Window]?

查看:83
本文介绍了什么是[对象窗口]?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Google Translate, has some bookmark let for translate with 1 click, for example:

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),但我想要它会打开一个新窗口(标签)进行翻译。所以改为:

This javascript code, opens the translator page in the current page (target=_self), but I want it opens a new window (tab) for translate. so changed to:

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);};

我的问题在于:当我运行该代码时,它会为翻译打开一个新窗口,并且它;但非英文页面内容被 [对象窗口] 取代,但我不想更改原始页面内容......

My problem is here: when I run that code, it opens a new window for translate, and do it; but the non-english page content replaced with [object Window], but I don't want to change original page content ...

我能做什么?

谢谢..

推荐答案

最后添加 void(0),因此没有值。如果最后一个表达式有一个值(在本例中是一个窗口),页面将替换为它。

Add void(0) at the end, so there will be no value. If the last expression has a value (in this case a window), the page is replaced with it.

这篇关于什么是[对象窗口]?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆