next up previous
Next: Messages and Confirmations Up: JavaScript Examples Previous: Manipulating Windows

Opening a New Window

The open() method

Recall from last lecture window object definition :

open("URL ", "name ")
close()

toolbar=[1|0]
location=[1|0]
directories=[1|0]
status=[1|0]
menubar=[1|0]
scrollbars=[1|0]
resizable=[1|0]
width=pixels
height=pixels

So our JavaScript can be developed to:

The Code is as follows:

<html>
<head>
 <script language=javascript>
 <!--
  function Load(url){
    
    newwin = open(url, "newwin",
                  'status=0,
                   toolbar=0,
                   resizable=0,
                   width=500,
                   height=700');
     }
 //-->
 </script>
</head>

<body>
  <a href="" 
   onClick="Load('http://www.cs.cf.ac.uk')">
   New page</a>
</body>
</html>

The basic operation of the code is:

Second Example: Web Advertising

<html>
<head>
 <script language=javascript>
 <!--
  function Load(url){
    
    newwin = open(url, "newwin",
             'status=0,toolbar=0,
              resizable=0,
              width=500,
              height=700');
     }
 //-->
 </script>
</head>

<body onLoad="Load('ad.html')">
  
  
  <h1> MAIN  PAGE HERE</h1>
</body>
</html>


next up previous
Next: Messages and Confirmations Up: JavaScript Examples Previous: Manipulating Windows
Dave Marshall
9/28/2001