Javascript - The Window Object

javascript-dom

How to close window without warning?
How to detect the close button?

// JavaScript - The window object:

// Properties:

.frames: an array containing all frame objects
.parent
.self
.top: refer to the top most browser window of a series of nested windows.
.status
.name
.defaultStatus: specifies the default status message
.opener: identifies the parent
.closed: identifies whether the window is closed
.document
.history
.length: identifies the number of frames contained
.location
.name: identifies the name of the window
.offscreenBuffering: used to load all of windows' elements before displaying
.window: a synonym that identifies the current window being referenced

// Methods:

.alert
.confirm
.prompt

.close
.open
.print()

.setTimeout
.setTimeout(function, delay) 
.clearTimeout

.setInterval
.setInterval(function, delay)
.clearInterval(id)

.parseInt
.parseFloat

.escape
.unescape
.encodeURI
.encodeURIComponet
.encode

// Events:
onload
onunload
onerror

A confirm dialog box presents a message in a modal dialog box along with the OK 
and Cancel buttons. When window.confirm is invoked, JavaScript execution is 
paused and code waits for the user's input. If the user clicks on the OK button, 
window.confirm returns true. If the user clicks on the Cancel button, 
window.confirm returns false:

if (window.confirm("Are you sure that you want to proceed?")) {
} else {
}

The window.prompt let you display a message. It also display a field for the 
user to type data, and two buttons (OK and Cancel). You can supply prewritten 
answer so that the user can just click on the OK button (or press Enter) to 
accept that answer without further typing. It is important to supply both 
parameters to window.prompt method. If you do not want to supply a default 
answer, provide an empty string as the second parameter:

var entry = window.prompt("Enter a number between 1 and 10:", "");
if (entry != null) {
}

variableName = open("URL","windowName", "option=value,option=value...");
var win1 = open("first.html","first","resizable=no,height=100,width=100");
status: yes | no
scrollbar: yes | no
toolbar: yes | no
menubar: yes | no
location: yes | no
directories: yes | no
resizable: yes | no
width: integer
height: integer

How to use window.confirm?

A confirm dialog box presents a message in a modal dialog box along with the OK and Cancel buttons. When window.confirm is invoked, JavaScript execution is paused and code waits for the user's input. If the user clicks on the OK button, window.confirm returns true. If the user clicks on the Cancel button, window.confirm returns false:

if (window.confirm("Are you sure that you want to proceed?")) {
} else {
}

What is the purpose of window.prompt?

The window.prompt let you display a message. It also display a field for the user to type data, and two buttons (OK and Cancel). You can supply prewritten answer so that the user can just click on the OK button (or press Enter) to accept that answer without further typing. It is important to supply both parameters to window.prompt method. If you do not want to supply a default answer, provide an empty string as the second parameter:

var entry = window.prompt("Enter a number between 1 and 10:", "");
if (entry != null) {
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License