A new page will open in a new window or tab.
Click a button:
// sample-4-write.js
// This sample shows writing a window
// global variable for the new window object
var winObj;
// open a new window with cleo.html
function newWindow(my_button_number)
{
var my_begin = "show number ";
var my_text = "The button you pressed is: ";
var my_end = "";
var my_features = "height=394,width=288,top=394,left=288,resizable=yes";
// if the window does not exist, or is closed, open it
if( typeof(winObj) == "undefined" || winObj.closed )
{
// empty string for the page name means we get an empty window. We will write the html.
winObj = open("", "writePage", my_features);
}
// if the window exists and is open, write to it
if( typeof(winObj) != "undefined" && ! winObj.closed )
{
// document open will erase the previous contents of the window
winObj.document.open();
winObj.document.writeln(my_begin);
winObj.document.writeln(my_text);
winObj.document.writeln(my_button_number);
winObj.document.writeln(my_end);
// document close must be used after document open and the write statments
winObj.document.close();
// if we are writing into an existing window, we must be sure it has focus
winObj.focus();
}
}
// close the new window
function closeWindow()
{
// if the window exists and is open, close it
if( typeof(winObj) != "undefined" && ! winObj.closed )
{
winObj.close();
}
}