Help Center

Local Navigation

Object: Location

Availability

BlackBerry® Device Software version 4.6 or later

Extends

Window

The Location object is a property of the Window object. This object accesses the URL of the web page being displayed in the BlackBerry® Browser.

A URL is composed of some or all of the following components:

protocol://hostname:port/path?query#fragment.

Location properties

Property name

Type

Description

Status

Support level

Availability

hash

DOMString

Specifies the anchor portion of the URL, including the leading hash mark, if one exists.

writable

Not part of any standard.

4.6 or later

host

DOMString

Specifies the URL hostname and port.

writable

Not part of any standard.

4.6 or later

hostname

DOMString

Specifies the hostname portion of the URL.

writable

Not part of any standard.

4.6 or later

href

DOMString

Specifies the entire URL.

writable

Not part of any standard.

4.6 or later

pathname

DOMString

Specifies the pathname portion of the URL.

writable

Not part of any standard.

4.6 or later

port

DOMString

Specifies the port portion of the URL.

read only

Not part of any standard.

4.6 or later

protocol

DOMString

Specifies the protocol portion of the URL.

writable

Not part of any standard.

4.6 or later

search

DOMString

Specifies the URL query string portion of the URL, including the question mark.

writable

Not part of any standard.

4.6 or later

Location methods

Method name

Description

Support level

Availability

assign()

Loads a new document.

Not part of any standard.

4.6 or later

replace()

Replaces the current web page with the web page at the given URL.

Not part of any standard.

4.6 or later

reload()

Reloads the current web page.

Not part of any standard.

4.6 or later

toString()

Returns the URL of the Location object’s URL.

Not part of any standard.

4.6 or later

Method: location.assign()

Availability

BlackBerry® Device Software version 4.6 or later

The assign() method loads a new document. Unlike location.replace(), when the given URL is loaded, the old URL is still available in the BlackBerry® Browser History list.

Syntax

location.assign( URL )

Parameters

Parameter

Type

Description

URL

String

The URL to load.

Return values

None.

Exceptions

None.

Method: location.reload()

Availability

BlackBerry® Device Software version 4.6 or later

The reload() method reloads the current web page.

Syntax

location.reload( forceGet )

Parameters

Parameter

Type

Description

forceGet

boolean

When true, indicates that the page will always be reloaded from the server. When false, or unspecified, the page can be reloaded from the BlackBerry® Browser cache, if it is available and still valid.

Return values

None.

Exceptions

None.

Method: location.replace()

Availability

BlackBerry® Device Software version 4.6 or later

The replace() method replaces the current web page with the web page at the given URL. This method differs from Location.assign() in that when the old URL is replaced, it is not saved in the History list. As a result, the user will have no way to navigate back to it.

Syntax

location.replace( URL )

Parameters

Parameter

Type

Description

URL

String

The URL to replace the current URL with.

Return values

None.

Exceptions

None.

Method: location.toString()

Availability

BlackBerry® Device Software version 4.6 or later

The toString() method returns the URL of the web page as a string.

Syntax

location.toString()

Parameters

None.

Return values

Returns the current URL (the value of location.href) as a string value.

Exceptions

None.

Next topic: Object: MimeType
Previous topic: Window API

Was this information helpful? Send us your comments.