How to open a new Window in JavaScript?

Poster
Posted by Poster under JavaScript category on | Views : 4394
Use following function

// open new window with specified path
function OpenWindow(url)
{
newwindow = window.open(url, 'mywindow', 'width=500,height=400');
newwindow.focus();
}


where window.open parameters are like this

1st parameter: is the actual url to open like "http://www.dotentfunda.com"
2nd parameter is the name of the new window, you can refer in your code
3rd parameter is the property of the window you can specify (for all property details, see http://www.pageresource.com/jscript/jwinopen.htm)

You can use above function like this
For Link <a href="javascript:OpenWindow('http://www.dotnetfunda.com')">Open DotNetFunda.Com</a>
For Button <input type="button" value="Open New Window" onClick="OpenWindow('http://www.dotnetfunda.com')" />

Comments or Responses

Login to post response