A new page will open in a new window or tab.
Click a button:





A copy of the JavaScript functions in the head element:

// sample-4-write.js
// This sample shows writing a window

// global variable for the new window object
var winObj;

// open a new window
function newWindow(my_button_number)
  {
  // One of the properties of the window is the screen it is within
  // Use the screen and window properties to compute the position for the window, to center it in the screen
  // If the window is smaller than the screen, put the window in the top left
  // This code is somewhat similar to McDuffie Script 11.13
  
  var my_width  = 250;
  var my_height = 300;
  // Position across from the left
  var xPos = screen.availWidth > my_width ? screen.availWidth/2 - my_width/2 : 0 ;
  // Position down from the top
  var yPos = screen.availHeight > my_height ? screen.availHeight/2 - my_height/2 : 0 ;

  // html text to be written into the new page
  var my_begin = "<html><head><title>show number</title></head><body>";
  var my_text  = "The button you pressed is: ";
  var my_end   = "</body></html>";
  var my_features = "height=" + my_height; 
  my_features += ",width=" + my_width; 
  my_features += ",top=" + yPos;
  my_features += ",left=" + xPos;
  my_features += ",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();
    }
  }