I am using MVC3 and jQuery. I am trying to open an external website. I am using the click event (and not a link) because I have some custom logic that will add values to a query string of the external site it is calling.
The JavaScript window.open
function is opening a new window, however it is pre-pending the original website's URL to the begining of the external website's URL.
Here is the jQuery code I am using:
$(function () {
$("#btnTransfer").click(function () {
//custom logic
window.open('http:\\www.google.com');
});
The new window opens with the URL of:
http://localhost:28761/www.google.com
Any ideas?
I have tried using _blank
as the name.
Your slashes are backwards:
window.open('http:\\www.google.com');
should be
window.open('http://www.google.com');
with the wrong slashes it would be interpreted as a relative url.
you url is incorrect. You need to use forward slashes not backslashes.
window.open('http://www.google.com');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.