Window : Window Object : Window JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Window » Window Object »

 

Window











The Window object is a JavaScript object created when a

, , or tag is encountered.

Instances of this object can also be created by using the Window.open() method.







































































































































































































































Methods/Properties Description
alert Loads an alert dialog box with the text string passed.
back Loads the previous page in place of the window instance.
blur Removes the focus from a window.
captureEvents Sets the window to capture all events of a specified type.
clearInterval Clears the interval set with the setInterval method.
clearTimeout Clears the timeout set with the setTimeout method.
close Closes the instance of the window.
confirm Displays a confirmation dialog box.
disableExternalCapture Disables external event capturing.
enableExternalCapture Enables external event capturing for the pages loaded from other servers.
find Displays a Find dialog box where the user can enter text to search the _current page.
focus Assigns the focus to the specified _window instance.
forward Loads the next page in place of the window instance.
handleEvent Invokes the handler for the event passed.
home Loads the user's specified home page in place of the window instance.
moveBy Moves the window by the amounts specified.
moveTo Moves the window to the specified location.
open Opens a new instance of a window.
print Invokes the Print dialog box so the user can print the current window.
prompt Displays a prompt dialog box.
releaseEvents Releases the captured events of a specified type.
resizeBy Resizes the window by the specified amount.
resizeTo Resizes the window to the specified size.
routeEvent Passes the events of a specified type to be handled natively.
scroll Scrolls the document in the window to a specified location.
scrollBy Scrolls the document in the window by a specified amount.
scrollTo Scrolls the document, both width and height, in the window to a specified location.
setInterval Invokes a function or evaluates an expression every time the number of milliseconds has passed.
setTimeout Invokes a function or evaluates an expression when the number of milliseconds has passed.
stop Stops the current window from loading other items within it.
closed Specifies if the window instance has been closed.
defaultStatus Is the default message in the window's status bar.
document References all the information about the document within this window. See the Document object for more information.
frames References all the information about the frames within this window. See the Frame object for more information.
history References the URLs the user has _visited.
innerHeight Contains the height of the display area of the current window in pixels.
innerWidth Contains the width of the display area of the current window in pixels.
length Represents the number of frames in the current window.
location Contains the current URL loaded into the window.
locationbar Reference to the browser's location bar.
menubar Reference to the browser's menu bar.
name Name of the window.
opener Contains the name of the window from which a second window was opened.
outerHeight Contains the height of the outer area of the current window in pixels.
outerWidth Contains the width of the outer area of the current window in pixels.
pageXOffset Contains the x-coordinate of the current window.
pageYOffset Contains the y-coordinate of the current window.
parent Reference to the upper most window that is displaying the current frame.
personalbar Reference to the browser's personal bar.
scrollbars Reference to the browser's scroll bars.
self Reference for the current window.
status Reference to the message in the window's status bar.
statusbar Reference to the browser's status bar.
toolbar Reference to the browser's tool bar.
top Reference to the upper most window that is displaying the current frame.
window Reference for the current window.




When using the close() and open() methods, you must take the instance's name when called within an event handler.












<html>
    <head>
    <script language="JavaScript">
    <!--
    function openWin(){
      var myBars = 'directories=no,location=no,menubar=no,status=no';
      myBars += ',titlebar=no,toolbar=no';
      var myOptions = 'scrollbars=no,width=400,height=200,resizeable=no';

      var myFeatures = myBars + ',' + myOptions;

      var myReadme = "This is a test";

      var newWin = open('', 'myWin', myFeatures);

      newWin.document.writeln('<form>');

      newWin.document.writeln('<table>');
      newWin.document.writeln('<tr><td>Readme');
      newWin.document.writeln('</td></tr>');
      newWin.document.writeln('<tr valign=TOP><td>');
      newWin.document.writeln('<textarea cols=45 rows=wrap=SOFT>');
      newWin.document.writeln(myReadme + '</textarea>');
      newWin.document.writeln('</td></tr>');
      newWin.document.writeln('<tr><td>');
      newWin.document.writeln('<input type=BUTTON value="Close"');
      newWin.document.writeln(' onClick="window.close()">');
      newWin.document.writeln('</td></tr>');
      newWin.document.writeln('</table></form>');

      newWin.document.close();
      newWin.focus();
    }
    -->
    </script>
    </head>
    <body>
    <form>
      <b>Click the following button to open a new window: </b>
      <input type=BUTTON value="Open" onClick='openWin()'>
    </form>
    </body>
    </html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Window
» Window Object