Redirect outside the current domain using javascript
I want to redirect to another website outside of my domain, such as this:
<img src="http://url.to.file.which/not.exist" onerror=wi开发者_如何学Pythonndow.open("www.google.com","xss",'height=500,width=500');>
I put the above code into a simple html file. However, it keeps appending the file path before "www.google.com" when the pop up show up. Is there a way to remove?
You missed the protocol - http(s)://
- before the domain
<img src="http://url.to.file.which/not.exist" onerror=window.open("https://www.google.com","xss",'height=500,width=500');>
Use the full URL: window.open("http://www.google.com"...
To use an absolute url you need to specify the protocol. In your case you want http://
.
So just change www.google.com
to http://www.google.com
精彩评论