Van icon

JAVASCRIPT BOM

Links


    //BOM  
    //Browser Object Model
    /
    


    //BOM WINDOW
    window.document.getElementById("header");  /*is the same as*/ document.getElementById("header");

    window.innerHeight
    window.innerWidth
    //* doesn't work in all browsers*/

    var w = window.innerWidth
    || document.documentElement.clientWidth
    || document.body.clientWidth;

    var h = window.innerHeight
    || document.documentElement.clientHeight
    || document.body.clientHeight;

    //Other methods:
    window.open() // open a new window
    window.close() // close the current window
    window.moveTo() // move the current window
    window.resizeTo() // resize the current window
    


    //BOM SCREEN
    //Can be written without the window prefix
    screen.width
    screen.height
    screen.availWidth //returns the width of the visitor's screen, in pixels, minus interface features like the Windows Taskbar.
    screen.availHeight //returns the height of the visitor's screen, in pixels, minus interface features like the Windows Taskbar.
    screen.colorDepth //umber of bits used to display one color.
    screen.pixelDepth // depth of the screen.


    //BOM WINDOW LOCATION
    window.location.href returns the href (URL) of the current page
    window.location.hostname returns the domain name of the web host
    window.location.pathname returns the path and filename of the current page
    window.location.protocol returns the web protocol used (http: or https:)
    window.location.assign() loads a new document
    


    //BOM WINDOW HISTORY
    //window.history object can be written without the window prefix.
    history.back() - same as clicking back in the browser
    history.forward() - same as clicking forward in the browser


    //BOM WINDOW NAVIGATOR
    //The window.navigator object can be written without the window prefix.
    navigator.appName
    navigator.appCodeName
    navigator.platform
    


    //BOM 
    //The window.navigator object can be written without the window prefix.
    navigator.appName //returns the application name of the browser:
    navigator.appCodeName
    navigator.platform
    navigator.cookieEnabled //returns true if cookies are enabled, otherwise false


    //BOM POPUP BOXES
    window.alert()
    window.confirm()
    window.prompt()
    


    //BOM TIMING
    setTimeout(function, milliseconds)
    setInterval(function, milliseconds)


    //BOM COOKIES
    //It gets deleted when browser is closed
    document.cookie = "username=John Doe";
    document.cookie = "username=John Doe; expires=Thu, 18 Dec 2013 12:00:00 UTC";
    document.cookie = "username=John Doe; expires=Thu, 18 Dec 2013 12:00:00 UTC; path=/";