使用javascript在当前域之外重定向

时间:2011-08-24 08:46:13

标签: javascript xss

我想重定向到我域外的其他网站,例如:

<img src="http://url.to.file.which/not.exist" onerror=window.open("www.google.com","xss",'height=500,width=500');>

我把上面的代码放到一个简单的html文件中。但是,当弹出窗口显示时,它会继续在“www.google.com”之前附加文件路径。有没有办法删除?

3 个答案:

答案 0 :(得分:3)

您错过了协议 - http(s):// - 在域

之前
<img src="http://url.to.file.which/not.exist" onerror=window.open("https://www.google.com","xss",'height=500,width=500');>

答案 1 :(得分:2)

使用完整网址:window.open("http://www.google.com"...

答案 2 :(得分:2)

要使用绝对URL,您需要指定协议。在您的情况下,您需要http://

所以只需将www.google.com更改为http://www.google.com

即可