Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Web
Expertise: Beginner
May 14, 1999

Open a Separate Child Browser Window Using JavaScript

You probably have seen some Web sites that automatically launch new windows in your browser to show an advertisement or an affiliated Web site. You can do this with the open method of the window object.
 
open(URL, WindowName, WindowFeatures)
If you specify a URL, the window will automatically open to that URL. WindowName allows you to specify which window to use. If you use a unique window name, a new window will be opened. If you use the name of an existing window, it will navigate to the given URL. Window features allow you to specify the height, width, menu bar, tool bar, status bar, and so forth.
 
<html>
<head>
<script language = javascript>
function openwindow(){
  w=open('','windowname','width=600,height=250,scrollbars,resizable,toolbar,status');
  with(w.document){
    write("<body>");
    write("This is a new window");
    write("</body>");
  }
  return false;
}

function openwindow2(){
    w=open('http://www.yahoo.com','windowname2','menubar');
}
</script>
</head>
<body>
<input type=button value="Click me to open a new window" onclick="openwindow()">
<input type=button value="Click me to goto Yahoo" onclick="openwindow2()">
</body>
</html>
William Wen
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date