window.open features string

Objective

  • Specify desired features when opening a window using JavaScript

The window.open features string

  • window.open may not work on modern browsers
  • window.open may open a new tab instead of a new window on modern browsers
  • setting the new windows features is non-standard, so this documentation is quickly becoming obsolete
  • you can open a window using: window.open(url, name, features, replace)
    • url specifies the page that will be loaded into the new window
    • name specifies the name of the window so that it can be used as the target of future links; you can also use "_blank" to specify a new window every time
    • features specifies what what features the new window should have
    • replace is a boolean value that determines if the new window will create a new entry in the browser history or replace the current entry
  • the features string is just a comma separated list of the options you want the new window to have
  • do not include spaces or quotes within the features string
  • including a feature in the features string means you want it included on the new window
  • if you don't specify any features, then the browser will use a default set of features
  • if you specify any feature, then the remaining (non-width/height) features will be dropped unless they are also specified
  • some browsers may put the new window into a new tab if the width and height aren't specified
  • some browsers may put the new window into a new tab no matter what
  • some browsers may put the new window into a new window no matter what
  • there is usually a minimum width and height, such as 100 by 100 pixels
  • here are the features you can set (these are non-standard)
    • width=nnn (where nnn is the desired width in pixels)
    • height=nnn (where nnn is the desired height in pixels)
    • left=nnn (where nnn is the screen position of the left edge in pixels)
    • top=nnn (where nnn is the screen position of the top edge in pixels)
    • location (specifies that the location box should be displayed)
    • menubar (specifies that the menu bar should be displayed)
    • resizable (specifies that the window should be resizable)
    • status (specifies that the status bar should be displayed)
    • toolbar (specifies that the tool bar should be displayed)
    • scrollbars (specifies that scrollbars should be displayed if they are needed)