2011-08-24 96 views
1

我想重定向到另一個網站我的域名,外面的當前域之外的像這樣的:重定向使用JavaScript

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

我把上面的代碼放到一個簡單的HTML文件。但是,當彈出窗口出現時,它會在「www.google.com」之前附加文件路徑。有沒有辦法刪除?

+0

這是因爲你提供了一個相對* * URI之前錯過了http://。 –

回答

2

您所訪問的

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

使用完整的URL:window.open("http://www.google.com"...

2

要使用你需要指定協議的絕對URL。在你的情況下,你想要http://

所以只是改變www.google.comhttp://www.google.com