Class: Browser::Location

Inherits:
Object show all
Includes:
Native
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

Instance Attribute Details

#fragmentString

Returns the hash fragment of the location URI.

Returns:

  • (String)

    the hash fragment of the location URI



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

alias_native :fragment, :hash

#hostString

Returns the host part of the location URI.

Returns:

  • (String)

    the host part of the location URI



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

alias_native :host

#pathString

Returns the path part of the location URI.

Returns:

  • (String)

    the path part of the location URI



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

alias_native :path, :pathname

#portInteger

Returns the port part of the location URI.

Returns:

  • (Integer)

    the port part of the location URI



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

alias_native :port

#queryString

Returns the query part of the location URI.

Returns:

  • (String)

    the query part of the location URI



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

alias_native :query, :search

#schemeString

Returns the scheme part of the location URI.

Returns:

  • (String)

    the scheme part of the location URI



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

alias_native :scheme, :protocol

#uriString

Returns the whole location URI.

Returns:

  • (String)

    the whole location URI



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

alias_native :uri, :href

Instance Method Details

#assign(url) ⇒ Object

Change the location.

Parameters:



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

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

#reload(force = false) ⇒ Object

Reload the page.

Parameters:

  • force (Boolean) (defaults to: false)

    whether to force the reload



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

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

#replace(url) ⇒ Object

Replace the current URL.

Parameters:



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

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

#to_sObject

Convert the location to a string.



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

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