Browser Object Model
Browser Object Model
function msg()
{
var a= prompt("Who are you?");
alert("Welcome " +a);
}
</script>
<body>
<h1> Example of the Prompt box with the use of function
<form>
<input type="button" value="click" onclick="msg()"/>
</form>
</body>
</html>
Note:
• The alert, confirm and prompt functions are
global functions.
• So it can be called using window object like
window.alert()
window.confirm()
window.prompt()
Points to Remember :
• Popup message can be shown using global functions -
alert(), confirm() and prompt().
• alert() function displays popup message with 'Ok' button.
• confirm() function display popup message with 'Ok' and
'Cancel' buttons. Use confirm() function to take user's
confirmation to proceed.
• prompt() function enables you to take user's input with
'Ok' and 'Cancel' buttons. prompt() function returns
value entered by the user. It returns null if the user does
not provide any input value.
Example of open() in javascript
<html>
<head>
<script type="text/javascript">
function msg()
{
open("https://www.javatpoint.com/window-object");
}
</script>
<body>
<h1> example of open() function</h1>
<form>
<input type="button" value="javatpoint" onclick="msg()">
</form>
</body>
</html>
Example of setTimeout() in javascript
It performs its task after the given milliseconds.
<script type="text/javascript">
function msg()
{
setTimeout(
function()
{
alert("Welcome to Javatpoint after 2 seconds")
},2000);
}
</script>
<input type="button" value="click" onclick="msg()"/>
JavaScript History Object
• The JavaScript history object represents an
array of URLs visited by the user.
• By using this object, you can load previous,
forward or any particular page.
• The history object is the window property, so
it can be accessed by:
window.history or
history
Property of JavaScript history object
There is only 1 property of history object.
No. Property Description
1 length returns the length of the
history URLs.
Methods of JavaScript history object
There are only 3 methods of history object.
No. Method Description
1 forward() loads the next page.
2 back() loads the previous page.
3 go() loads the given page number.
Example of history object
• history.back();//for previous page
• history.forward();//for next page
• history.go(2);//for next 2nd page
• history.go(-2);//for previous 2nd page
JavaScript Navigator Object
• The JavaScript navigator object is used for browser detection.
• It can be used to get browser information such as appName,
appCodeName, userAgent etc.
• The navigator object is the window property, so it can be
accessed by:
window.navigator
Navigator
Property of JavaScript navigator object
There are many properties of navigator object that returns
information of the browser.
Property of JavaScript navigator object
There are many properties of navigator object that returns information of the browser.
No. Property Description
1 appName returns the name
2 appVersion returns the version
3 appCodeName returns the code name
4 cookieEnabled returns true if cookie is enabled otherwise false
5 userAgent returns the user agent
6 language returns the language. It is supported in Netscape
and Firefox only.
7 userLanguage returns the user language. It is supported in IE only
8 Plugins returns the plugins. It is supported in Netscape and Firefox only.
9 systemLanguage returns the system language. It is supported in IE only.
10 mimeTypes[] returns the array of mime type. It is supported in Netscape
and Firefox only.
11 Platform returns the platform e.g. Win32
12 online returns true if browser is online otherwise false.