Window Object
Frames
<html>
<body>
<iframe src="[Link]
<iframe src="[Link]
<iframe src="[Link]
<script type="text/javascript">
for (var i=0; i<[Link]; i++)
{
frames[i].location="[Link]
}
</script>
</body>
</html>
History
<html>
<body>
<script type="text/javascript">
[Link]("Number of URLs in history list: " + [Link]);
</script>
</body>
</html>
Output
Number of URLs in history list: 2
Location
<html>
<body>
<script type="text/javascript">
[Link]([Link]);
</script>
</body>
</html>
Output:
http:
Name
<html>
<head>
<script type="text/javascript">
var myWindow;
function openWin()
{
myWindow=[Link]('','MsgWindow','width=200,height=100');
[Link]("This window's name is: " + [Link]);
}
</script>
</head>
<body>
<input type="button" value="Open 'myWindow' " onclick="openWin()" />
</body>
</html>
Navigator
<html>
<body>
<script type="text/javascript">
[Link]("Version info: " + [Link]);
</script>
</body>
</html>
Output:
Version info: 5.0 (Windows; en-US)
Screen
<html>
<body>
<script type="text/javascript">
[Link]("Available Width: " + [Link]);
</script>
</body>
</html>
Output:
Available Width: 1366
Self
<html>
<head>
<script type="text/javascript">
function check()
{
if ([Link]!=[Link])
{
[Link]("This window is not the topmost window! Am I in a frame?")
}
else
{
[Link]("This window is the topmost window!")
}
}
</script>
</head>
<body>
<input type="button" onclick="check()" value="Check window" />
</body>
</html>
Status
<html>
<body>
<script type="text/javascript">
[Link]="Some text in the status bar!!";
</script>
</body>
</html>
Document Object
Cookie
<html>
<body>
Cookies associated with this document:
<script type="text/javascript">
[Link]([Link]);
</script>
</body>
</html>
Output:
Cookies associated with this document:
__utma=119627022.52052259.1296985780.1297145346.1297184070.5;
__utmz=[Link]=google|utmccn=(organic)|utmcmd=organic|
utmctr=w3schools%20javascript;
ASPSESSIONIDSCDQDCBQ=FOLHCFKADIEAOLOFKOBIDKOH;
__utmb=119627022.37.10.1297184070; __utmc=119627022
Domain
<html>
<body>
The domain name for the server that loaded this document:
<script type="text/javascript">
[Link]([Link]);
</script>
</body>
</html>
Output:
The domain name for the server that loaded this document is [Link]
Last Modified
<html>
<body>
<script type="text/javascript">
[Link]([Link]);
</script>
</body>
</html>
Output:
01/14/2011 20:22:35
Title
<html>
<head>
<title>My title</title>
</head>
<body>
The title of the document is:
<script type="text/javascript">
[Link]([Link]);
</script>
</body>
</html>
Output:
The title of the document is: My title
URL
<html>
<body>
The full URL of this document is:
<script type="text/javascript">
[Link]([Link]);
</script>
</body>
</html>
Output:
The full URL of this document is: [Link]
filename=tryjsref_doc_url
Form Object
Action
<html>
<body>
<form id="frm1" action="form_action.asp">
First name: <input type="text" name="fname" value="Donald" /><br />
Last name: <input type="text" name="lname" value="Duck" /><br />
<input type="submit" value="Submit" />
</form>
The value of the action attribute is:
<script type="text/javascript">
[Link]([Link]("frm1").action);
</script>
</body>
</html>
Output:
The value of the action attribute is: [Link]
Length
<html>
<body>
<form id="frm1" action="form_action.asp">
First name: <input type="text" name="fname" value="Donald" /><br />
Last name: <input type="text" name="lname" value="Duck" /><br />
<input type="submit" value="Submit" />
</form>
The number of elements in "frm1" are:
<script type="text/javascript">
[Link]([Link]("frm1").length);
</script>
</body>
</html>
Output:
The number of elements in "frm1" are: 3
Method
<html>
<body>
<form id="frm1" action="form_action.asp" method="get">
First name: <input type="text" name="fname" value="Donald" /><br />
Last name: <input type="text" name="lname" value="Duck" /><br />
<input type="submit" value="Submit" />
</form>
The method for sending form-data is:
<script type="text/javascript">
[Link]([Link]("frm1").method);
</script>
</body>
</html>
Output:
The method for sending form-data is: get
Name
<html>
<body>
<form id="frm1" name="form1">
First name: <input type="text" name="fname" value="Donald" /><br />
Last name: <input type="text" name="lname" value="Duck" /><br />
</form>
The name of the form is:
<script type="text/javascript">
[Link]([Link]("frm1").name);
</script>
</body>
</html>
Output:
The name of the form is: form1
Target
<html>
<body>
<form id="frm1" action="form_action.asp" target="_blank">
First name: <input type="text" name="fname" value="Donald" /><br />
Last name: <input type="text" name="lname" value="Duck" /><br />
<input type="submit" value="Submit" />
</form>
The value of the target attribute is:
<script type="text/javascript">
[Link]([Link]("frm1").target);
</script>
</body>
</html>
Output:
The value of the target attribute is: _blank
Navigator Object
Appcode name
<html>
<body>
<script type="text/javascript">
[Link]("CodeName: " + [Link]);
</script>
</body>
</html>
Output:
CodeName: Explorer
AppName
<html>
<body>
<script type="text/javascript">
[Link]("Name: " + [Link]);
</script>
</body>
</html>
Output:
Name: Firefox
Appversion
<html>
<body>
<script type="text/javascript">
[Link]("Version info: " + [Link]);
</script>
</body>
</html>
Output:
Version info: 5.0 (Windows; en-US)
Cookie Enabled
<html>
<body>
<script type="text/javascript">
[Link]("Cookies enabled: " + [Link]);
</script>
</body>
</html>
Output:
Cookies enabled: true
Platform
<html>
<body>
<script type="text/javascript">
[Link]("Platform: " + [Link]);
</script>
</body>
</html>
Output:
Platform: Win32 // windows 32 bit
Screen Object
AvailHeight
<html>
<body>
<script type="text/javascript">
[Link]("Available Height: " + [Link]);
</script>
</body>
</html>
Output:
Available Height: 738
AvailWidth
<html>
<body>
<script type="text/javascript">
[Link]("Available Width: " + [Link]);
</script>
</body>
</html>
Output:
Available Width: 1366
Color Depth
<html>
<body>
<script type="text/javascript">
[Link]("Color Depth: " + [Link]);
</script>
</body>
</html>
Output:
Color Depth: 24
Height
<html>
<body>
<script type="text/javascript">
[Link]("Total Height: " + [Link]);
</script>
</body>
</html>
Output:
Total Height: 768
Width
<html>
<body>
<script type="text/javascript">
[Link]("Total Width: " + [Link]);
</script>
</body>
</html>
Output:
Total Width: 1366