Opening a new window with JavaScript

The following code is placed in the <head> section of the html file:

<script>

function newWindow(){
   window.open("window.html", "exampleWin", "width=650,height=300")
}

</script>

The open.window method has 3 parameters:

  1. The URL of the page to be leaded into the window. window.html in the example above.
  2. The name of the window. exampleWin in the example above
  3. The list of properties. In the example above, only the width and height properties are used but there are others.

The window can be activated in a number of ways but having the user click a link is useful. Here's the code for the link:

<a href="javascript: newWindow()">text to click</a>

Now try it for real. Click this link to see a new window.