Open new window and set window location in JavaScript

Description

The following code shows how to open new window and set window location.

Example


<HTML>
<HEAD>
<SCRIPT language="JavaScript">
function new_win()<!-- w w w  .j  av a  2 s . com-->
{
window.open("http://www.java2s.com","mywin","width=400,height=300,screenX=50,left=50,screenY=50,top=50,status=yes,menubar=yes");
}
</SCRIPT>
</HEAD>
<BODY>
<FORM name="myform">
<INPUT TYPE="button" value="Open New Window" onClick="new_win()">
</FORM>
</BODY>
</HTML>

Click to view the demo

The code above generates the following result.

Open new window and set window location in JavaScript