You wanted to access the root document of server www.google.com, which is done using the url https://www.google.com/. You provided a relative url for document www.google.com instead.
Keep in mind that window.open accepts both relative and absolute urls, so it can't assume you left out https:// as it does when you use www.google.com in the address bar.
Maybe an example will help. Say the current page is http://www.example.com/dir/foo.html.
window.open("popup.html", "_blank")openshttp://www.example.com/dir/popup.html.window.open("www.google.com", "_blank")therefore openshttp://www.example.com/dir/www.google.com.
The browser has no way of knowing you actually wanted https://www.google.com/ when you said you wanted http://www.example.com/dir/www.google.com since the latter could be valid.
You wanted to access the root document of server www.google.com, which is done using the url https://www.google.com/. You provided a relative url for document www.google.com instead.
Keep in mind that window.open accepts both relative and absolute urls, so it can't assume you left out https:// as it does when you use www.google.com in the address bar.
Maybe an example will help. Say the current page is http://www.example.com/dir/foo.html.
window.open("popup.html", "_blank")openshttp://www.example.com/dir/popup.html.window.open("www.google.com", "_blank")therefore openshttp://www.example.com/dir/www.google.com.
The browser has no way of knowing you actually wanted https://www.google.com/ when you said you wanted http://www.example.com/dir/www.google.com since the latter could be valid.
You have to prepend http:// in your url:
$(document).ready(function () {
$('#mybtn').on('click', function () {
window.open("http://www.google.com", '_blank');
});
});
Fix: http://jsfiddle.net/FUYTY/4/
Open URL in new window with JavaScript - Stack Overflow
window.open external link opening in new tab
Launch Chrome Browser without Address Bar, Tabs or Bookmarks on Windows PC (not Full-screen)
[deleted by user]
Videos
Use window.open():
<a onclick="window.open(document.URL, '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes');">
Share Page
</a>
This will create a link titled Share Page which opens the current url in a new window with a height of 570 and width of 520.
Just use window.open() function? The third parameter lets you specify window size.
Example
var strWindowFeatures = "location=yes,height=570,width=520,scrollbars=yes,status=yes";
var URL = "https://www.linkedin.com/cws/share?mini=true&url=" + location.href;
var win = window.open(URL, "_blank", strWindowFeatures);