Welcome to Bucaro TecHelp!

Bucaro TecHelp
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact RSS News Feeds News Feeds

Victims of Sandy Hook

Stop the Slaughter of Innocents. Congress is bought and paid for by gun lunatics and gun promotion groups. If you want to live in a safe America, help buy Congress back for America. Send a donation to Mayors Against Illegal Guns, 909 Third Avenue, 15th Floor New York, NY 10022

The Java Script window.open Method

To create and open a new window, use the window.open method. The code shown below causes a new blank window to open as the webpage loads.

<html>
<head>
</head>
<body>

<script type="text/javascript">

window.open();

</script>

</body>
</html>

The code shown below causes a new window to open and display a specific document.

<html>
<head>
</head>
<body>

<script type="text/javascript">

window.open("path/filename.ext");

</script>

</body>
</html>

In the code shown below, the window.open method is placed inside a function which is placed in a Java Script code block in the head section of the webpage. When the user clicks on a link in the webpage, the function is executed and the new window is opened. The function also writes the text "HELLO" to the new window and sets its title bar text to "HELLO". You need to call the window.stop method to close the new window for writing.

<html>
<head>

<script type="text/javascript">
function open_window()
{
  var myWin = window.open();
  myWin.document.write("HELLO");
  myWin.document.title = "HELLO";
  myWin.stop();
}
</script>

</head>
<body>

<a href="#" onclick="open_window()">Open Window</a>

</body>
</html>

The complete syntax for the window.open method is shown below.

window.open(URL, name, features, replace);

URL specifies the URL or file name of the page to open. If no URL or file name is specified, a new window with the title Blank Page will be opened.

name specifies the name or target of the window. A target attribute can be one of the following values:

_blank URL is loaded into a new window
_parent URL is loaded into the parent frame
_self URL replaces the current page
_top URL replaces any framesets that may be loaded

features is a comma-separated list of windows features. The following features are supported:

left=pixelsThe left position of the window
top=pixelsThe top position of the window
width=pixelsThe width of the window
height=pixelsThe height of the window
resizable=yes|no|1|0Whether or not to make the window resizable
scrollbars=yes|no|1|0Whether or not to display scroll bars
titlebar=yes|no|1|0Whether or not to display the title bar
menubar=yes|no|1|0Whether or not to display the menu bar
location=yes|no|1|0Whether or not to display the address field
toolbar=yes|no|1|0Whether or not to display the browser toolbar
status=yes|no|1|0Whether or not to add a status bar

replace specifies whether the URL replaces the current entry in the history list or if it creates a new entry in the history list. true URL replaces the current entry in the history list. false URL creates a new entry in the history list.

RSS Feed RSS Feed



Follow Stephen Bucaro Follow @Stephen Bucaro


Web Design Sections

Fire HD
[Site User Agreement] [Privacy Policy] [Site map] [Search This Site] [Contact Form]
Copyright©2001-2016 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268