Guild Media
How the Web Was Won - Comentaries and a smattering of tech nerdiness.
Web Design Development Programming, SEO, Internet Marketing
    • About Us
    • Portfolio
      • Flash
        • aspen_en
      • Websites
    • Programming
      • html_en
        • html-escape-codes_en
        • CSS Transparency
      • javascript_en
        • frame-buster_en
        • JavaScript History Object
        • JavaScript Location Object
      • PHP
        • WordPress Plugins
        • Admin Drop Menus for BBPress
    • services_en
      • design_en
      • development_en
      • hosting_en
      • seo_en
    • User defined URI

JavaScript Location Object

OBJECT: Location

The Location object is part of a Window object and is accessed
through the window.location property. It contains the complete
URL of a given Window object, or, if none is specified, of the
current Window object. All of its properties are strings representing
different portions of the URL, which generally takes the following form:
 
<protocol>//<host>[:<port>]/<pathname>[<hash>][<search>]
 
You can create a Location object by simply assigning a URL
to the location property of an object:
 
Code:
window.location = "file:///C:/Projects"
 
PROPERTIES
 
hash Property
The hash property is a string beginning with a hash (#), that
specifies an anchor name in an HTTP URL.
 
Syntax: location.hash
 
host Property
The host property is a string comprising of the hostname
and port strings.
 
Syntax: location.host
 
hostname Property
The hostname property specifies the server name, subdomain and
domain name (or IP address) of a URL.
 
Syntax: location.hostname
 
href Property
The href property is a string specifying the entire URL, and
of which all other Link properties are substrings.
 
Syntax: location.href
 
pathname Property
The pathname property is a string portion of a URL specifying
how a particular resource can be accessed.
 
Syntax: location.pathname
 
port Property
The port property is a string specifying the communications port
that the server uses.
 
Syntax: location.port
 
protocol Property
The protocol property is the string at the beginning of a URL,
up to and including the first colon (:), which specifies the method
of access to the URL.
 
Syntax: location.protocol
 
search Property
The search property is a string beginning with a question mark
that specifies any query information in an HTTP URL.
 
Syntax: location.search
 
METHODS
 
reload Method
The reload method forces a reload of the window's current document,
i.e. the one contained in the Location.href property.
 
Syntax: location.reload([forceGet])
 
replace Method
The replace method replaces the current History entry
with the specified URL. After calling the replace method, you
cannot navigate back to the previous URL using the browser's Back button.
 
Syntax: location.replace(URL)

JavaScript Location Object

The JavaScript location object is a property of the window object. It can be used to control the web page displayed by the browser.

Properties

  • hash – The URL anchor part including the leading hash mark if one exists This is the part of the URL that is used to point to point to a particular part of a page where a named anchor is. The hash is the part containing the # sign that points to the particular page location.
  • host – The URL hostname and port. The URL http://ctdp.tripod.com:80/index.html has the host value of ctdp.tripod.com:80. The colon and port is only included when specified. The URL http://ctdp.tripod.com/index.html has the host value of ctdp.tripod.com.
  • hostname – The URL hostname section
  • href – The entire URL. The following code will load the home CTDP page:

    location.href="http://ctdp.tripod.com/" mce_href="http://ctdp.tripod.com/"

    The following code will display the URL of the current page:

    document.write(location.href)

  • pathname – The URL pathname section
  • port – The URL port section.
  • protocol – The URL protocol section including the colon after the protocol name. The values are normally http: or file:. The following JavaScript code may be used to identify the source of the URL.
    	switch (window.location.protocol)
    	{
    	case "http:":
    	document.write("From Web<BR>\n")
    	break
    	case "file:":
    	document.write("From Local computer<BR>\n")
    	break
    	default:
    	document.write("Unknown Source<BR>\n")
    	break
    	}
    	
  • search – The URL query string section. This is the section after and including the question mark.
  • target – The URL link's target name.

Methods

  • reload() – The current window document is reloaded. If a value of true is passed to the reload function, the reload is forced to do an HTTP GET of the document. This is not normally done but is useful when you think the server contents may be different from your cache.
  • replace(URL) – Requires a URL as a parameter. It loads the document at the URL on top of the current document. A new entry entry is not placed in the history object.
Bookmark to:


Hide Sites
  • Archives

    • ► 2009 (20)
      • September 2009
      • July 2009
      • April 2009
      • March 2009
      • February 2009
    • ► 2008 (29)
      • December 2008
      • November 2008
      • October 2008
      • September 2008
      • August 2008
      • July 2008
      • June 2008
      • March 2008
      • February 2008
      • January 2008
    • ► 2007 (35)
      • December 2007
      • November 2007
      • October 2007
      • September 2007
      • August 2007
      • July 2007
      • June 2007
      • May 2007
      • April 2007
      • March 2007
  • Categories

    • Animation
    • Apple
    • Blog
    • Browsers
    • Censorship
    • Copyright
    • CSS
    • Dell
    • Design
    • eCommerce
    • File Sharing
    • Firefox
    • Fun
    • Google
    • Hacking
    • Hardware
    • HTML5
    • Internet Explorer
    • Internet Marketing
    • Internet TV
    • JavaScript
    • law
    • Learning
    • Linux
    • Microsoft
    • New Media
    • Open Source
    • Open Source Community
    • OS
    • Privacy
    • Programming
    • Search Engines
    • Security
    • SEO
    • Social Networks
    • software
    • Tech Talk
    • Technology
    • The Matrix
    • Uncategorized
    • video
    • Virus
    • VoIP
    • WordPress
  • Blogroll

    • Alan Moore – SMLXL
    • beinArt
    • Kristine Lowe
    • Leo Plaw
    • Media Influencer
    • Rebecca Caroe
  • Firebug - Web Development Evolved
Copyright © 2010 Guild Media All Rights Reserved
RSS XHTML CSS Log in
Powered by Wordpress
This blog is protected by Dave's Spam Karma 2: 52 Spams eaten and counting...