Javascript Knowledge

  • what is javascript

  • javascript Variable
  • javascript function
  • javascript Event

  • JavaScript If
  • javascript for

  • javascript object
  • Javascript String
  • Javascript Date
  • Javacsript Array
  • Javascript Math

  • Javascript onclick
  • JavaScript onload

  • Javascript Frame
  • Javascript Image
  • Javascript Style
  • Javascript Textarea
  • Javascript Table
  • Javascript window
  • Javascript Location
  • Javacsript form
  • Javascript Checkbox
  • Javascript Input
  • Javascript Radio
  • Javascript Select
  • Javascript Submit

  • Javascript alert
  • Javascript close
  • Javascript confirm
  • Javascript Document open
  • Javascript getElementById
  • Javascript print
  • Javascript reload
  • Javascript remove
  • JavaScript replace
  • Javascript setTimeout
  • JavaScript split
  • JavaScript substring
  • Javascript window open
  • window showmodaldialog

  • Javascript href
  • Javascript IFrame
  • Javascript innerHTML
  • Javascript selectedindex
  • Javascript URL
  • Javascript window Location

  • javascript write to file
  • JavaScript write
  • javascript string to integer
  • Javascript popup
  • Javascript return
  • Javascript Obfuscator
  • Javascript disable
  • Javascript Hide
  • More others

    Javascript
    CSS
    PHP

     

    Javascript Window Location


    Location Object

    The Location object is an object that can be accessed through the location property of the Window object.

    The Location object contains information about the current URL.

    IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

    Location Object Properties

    Property

    Description

    IE

    F

    N

    W3C

    hash

    Sets or returns the part of the href property that follows the hash sign (#)

    3

    1

    2

     

    host

    Sets or returns the hostname and port number of the location or URL

    3

    1

    2

     

    hostname

    Sets or returns the hostname of the location or URL

    3

    1

    2

     

    href

    Sets or returns the entire URL

    3

    1

    2

     

    pathname

    Sets or returns the file name or path specified by the location object

    3

    1

    2

     

    port

    Sets or returns the port number associated with the URL

    3

    1

    2

     

    protocol

    Sets or returns the protocol part of the URL

    3

    1

    2

     

    search

    Sets or returns the part of the href property that follows the question mark (?)

    3

    1

    2

     

    Location Object Methods

    Method

    Description

    IE

    F

    N

    W3C

    assign("URL")

    Loads a new document

    4

    1

    2

     

    reload()

    Reloads the current document

    4

    1

    2

     

    replace("URL")

    Replaces the current document with the one specified

    4

    1

    3

     

    Example:

    <html>

    <head>

    <script type="text/javascript">

    function currLocation()

    {

    alert(window.location)

    }

    function newLocation()

    {

    window.location="http://www.w3schools.com"

    }

    </script>

    </head>

    <body>

    <input type="button" onclick="currLocation()" value="Show current URL">

    <input type="button" onclick="newLocation()" value="Change URL">

    </body>

    </html>

     





















     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

  • Javascript |