Home > DeveloperSection > Forums > JavaScript's window.open adds to url
sandy taylor
sandy taylor

Total Post:46

Points:324
Posted on    November-09-2014 10:54 PM

 ASP.NET MVC JQuery  JavaScript 
Ratings:


 1 Reply(s)
 621  View(s)
Rate this:

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 () {

            window.open('http:\\www.mindstick.com);

        });

The new window opens with the URL of:

http://www.mindstick.com

Any ideas?

I have tried using _blank as the name.

 



Lillian Martin

Total Post:27

Points:189
Posted on    November-10-2014 12:58 AM

Your slashes are backwards:

window.open('http:\\www.mindstick.com');

should be

window.open('http://www.mindstick.com');

with the wrong slashes it would be interpreted as a relative url.


Don't want to miss updates? Please click the below button!

Follow MindStick