js open new window code example

Example 1: open link in new tab javascript

window.open('https://www.codexworld.com', '_blank');

Example 2: javascript open link in new tab

function NewTab() { 
            window.open( 
              "https://www.yourURL.com", "_blank");
}

Example 3: javascript open url

window.location.href = "http://example.com/";

Example 4: javascript open new window

<a onclick="window.open(document.URL, '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes');">
Open New Window
</a>

Example 5: open new window javascript

window.open("LINK-HERE");

Example 6: javascript open new window with html content

var newWin = open('url','windowName','height=300,width=300');
newWin.document.write('html to write...');