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

Availability

hash

String

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

writable

4.6 or later

host

String

Specifies the URL hostname and port.

writable

4.6 or later

hostname

String

Specifies the hostname portion of the URL.

writable

4.6 or later

href

String

Specifies the entire URL.

writable

4.6 or later

pathname

String

Specifies the pathname portion of the URL.

writable

4.6 or later

port

String

Specifies the port portion of the URL.

read only

4.6 or later

protocol

String

Specifies the protocol portion of the URL.

writable

4.6 or later

search

String

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

writable

4.6 or later

Location methods

Method name

Description

Availability

assign()

Loads a new document.

4.6 or later

replace()

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

4.6 or later

reload()

Reloads the current web page.

4.6 or later

toString()

Returns the URL of the Location object’s URL.

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: MediaList

Was this information helpful? Send us your comments.