Class: Browser::Location

Inherits:
Object show all
Includes:
NativeCachedWrapper
Defined in:
opal/browser/location.rb

Overview

Allows manipulation of a location, usually from Window and DOM::Document.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from NativeCachedWrapper

#restricted?, #set_native_reference

Instance Attribute Details

#fragmentString

Returns the hash fragment of the location URI.

Returns:

  • (String)

    the hash fragment of the location URI



38
# File 'opal/browser/location.rb', line 38

alias_native :fragment, :hash

#hostString

Returns the host part of the location URI.

Returns:

  • (String)

    the host part of the location URI



43
# File 'opal/browser/location.rb', line 43

alias_native :host

#pathString

Returns the path part of the location URI.

Returns:

  • (String)

    the path part of the location URI



53
# File 'opal/browser/location.rb', line 53

alias_native :path, :pathname

#portInteger

Returns the port part of the location URI.

Returns:

  • (Integer)

    the port part of the location URI



58
# File 'opal/browser/location.rb', line 58

alias_native :port

#queryString

Returns the query part of the location URI.

Returns:

  • (String)

    the query part of the location URI



68
# File 'opal/browser/location.rb', line 68

alias_native :query, :search

#schemeString

Returns the scheme part of the location URI.

Returns:

  • (String)

    the scheme part of the location URI



63
# File 'opal/browser/location.rb', line 63

alias_native :scheme, :protocol

#uriString

Returns the whole location URI.

Returns:

  • (String)

    the whole location URI



48
# File 'opal/browser/location.rb', line 48

alias_native :uri, :href

Instance Method Details

#assign(url) ⇒ Object

Change the location.

Parameters:



13
14
15
# File 'opal/browser/location.rb', line 13

def assign(url)
  `#@native.assign(#{url.to_s})`
end

#full_pathObject

Returns the full path of the location URI, including the query string and fragment, eg. /site?a=b#c



73
74
75
# File 'opal/browser/location.rb', line 73

def full_path
  path + query + fragment
end

#reload(force = false) ⇒ Object

Reload the page.

Parameters:

  • force (Boolean) (defaults to: false)

    whether to force the reload



27
28
29
# File 'opal/browser/location.rb', line 27

def reload(force = false)
  `#@native.reload(force)`
end

#replace(url) ⇒ Object

Replace the current URL.

Parameters:



20
21
22
# File 'opal/browser/location.rb', line 20

def replace(url)
  `#@native.replace(#{url.to_s})`
end

#to_sObject

Convert the location to a string.



32
33
34
# File 'opal/browser/location.rb', line 32

def to_s
  `#@native.toString()`
end