JAVASCRIPT BOM AND EVENTS
Browser Object Model
The Browser Object Model (BOM) is used to interact with the browser.
The default object of browser is window means you can call all the functions of window by specifying window or directly
You can use a lot of properties (other objects) defined underneath the window object like document, history, screen, navigator, location, innerHeight, innerWidth,
1. WINDOW OBJECT
alert():
Displays the alert box containing message with ok button;
syntax:
<! DOCTYPE html> <html> <head> <title> style=font sizing </title> </head> <body> <script> window.alert("Hello"); </script> <body> <html> |
confirm():
Displays the confirm dialog box containing message with ok and cancle button.
syntax:
<! DOCTYPE html> <html> <head> <title> style=font sizing </title> </head> <body> <script> window.confirm("Hello"); </script> <body> <html> |
prompt():
Displays dialog box to get input from the user.
syntax:
<! DOCTYPE html> <html> <head> <title> style=font sizing </title> </head> <body> <script> var x = window.prompt("Hello"); document.write(x); </script> <body> <html> |
Open():
Open the new window
syntax:
<! DOCTYPE html> <html> <head> <title> style=font sizing </title> </head> <body> <button onclick="blog()"> Blog </button> <script> function blog(){
</script> <body> <html> |
close():
Close the current window
syntax:
<! DOCTYPE html> <html> <head> <title> style=font sizing </title> </head> <body> <script> close(); </script> <body> <html> |
innerHeight() and innerWidth():
syntax:
<! DOCTYPE html> <html> <head> <title> style=font sizing </title> </head> <body> <script> var h = window.innerHeight(); var w = window.innerWidth(); document.writh( h + " " + w ) </script> <body> <html> |
setTimeout():
performs action after specified time like calling function, evaluating expressions etc.