Package org.htmlunit.javascript.host
Class Location
java.lang.Object
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.javascript.HtmlUnitScriptable
org.htmlunit.javascript.host.Location
- All Implemented Interfaces:
Serializable
,Cloneable
,org.htmlunit.corejs.javascript.ConstProperties
,org.htmlunit.corejs.javascript.debug.DebuggableObject
,org.htmlunit.corejs.javascript.Scriptable
,org.htmlunit.corejs.javascript.SymbolScriptable
A JavaScript object for
Location
.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Method
private static final Method
private static final Method
private static final Method
private static final Method
private static final Method
private static final Method
private static final Method
private static final Method
private String
The current hash; we cache it locally because we don't want to modify the page's URL and force a page reload each time this changes.private static final org.apache.commons.logging.Log
private static final Method
private static final Method
private static final Method
private static final Method
private static final Method
private static final Method
private static final Method
private static final Method
private static final Method
private static final Method
private static final Method
private static final Method
private static final String
private Window
The window which owns this location object.Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Loads the new HTML document corresponding to the specified URL.private static String
decodeHash
(String hash) getDefaultValue
(Class<?> hint) Returns the JavaScript default value of this object.getHash()
Returns the hash portion of the location URL (the portion following the '#').private String
getHash
(boolean encoded) getHost()
Returns the host portion of the location URL (the '[hostname]:[port]' portion).Returns the hostname portion of the location URL.getHref()
Returns the location URL.Returns theorigin
property.Returns the pathname portion of the location URL.getPort()
Returns the port portion of the location URL.Returns the protocol portion of the location URL, including the trailing ':'.Returns the search portion of the location URL (the portion following the '?').private URL
getUrl()
Returns this location's current URL.void
initialize
(Window window, Page page) Initializes this Location.void
Creates an instance.Returns the location URL.void
reload
(boolean force) Reloads the current page, possibly forcing retrieval from the server even if the browser cache contains the latest version of the document.void
Reloads the window using the specified URL via a postponed action.void
Sets the hash portion of the location URL (the portion following the '#').void
Sets the hash portion of the location URL (the portion following the '#').void
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Sets the hash portion of the location URL (the portion following the '#').void
Sets the host portion of the location URL (the '[hostname]:[port]' portion).void
setHostname
(String hostname) Sets the hostname portion of the location URL.void
Sets the location URL to an entirely new value.void
setPathname
(String pathname) Sets the pathname portion of the location URL.void
Sets the port portion of the location URL.void
setProtocol
(String protocol) Sets the protocol portion of the location URL.void
Sets the search portion of the location URL (the portion following the '?').private void
Sets this location's URL, triggering a server hit and loading the resultant document into this location's window.Methods inherited from class org.htmlunit.javascript.HtmlUnitScriptable
clone, equivalentValues, get, getBrowserVersion, getClassName, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, getWithPreemption, has, hasInstance, initParentScope, makeScriptableFor, put, setClassName, setDomNode, setDomNode, setParentScope, setupPromise, setupRejectedPromise
Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setPrototype, size
-
Field Details
-
LOG
private static final org.apache.commons.logging.Log LOG -
UNKNOWN
- See Also:
-
window_
The window which owns this location object. -
methodAssign
-
methodReload
-
methodReplace
-
methodToString
-
getterHash
-
setterHash
-
getterHost
-
setterHost
-
getterHostname
-
setterHostname
-
getterHref
-
setterHref
-
getterOrigin
-
getterPathname
-
setterPathname
-
getterPort
-
setterPort
-
getterProtocol
-
setterProtocol
-
getterSearch
-
setterSearch
-
hash_
The current hash; we cache it locally because we don't want to modify the page's URL and force a page reload each time this changes.
-
-
Constructor Details
-
Location
public Location()Creates an instance.
-
-
Method Details
-
jsConstructor
public void jsConstructor()Creates an instance. -
initialize
Initializes this Location.- Parameters:
window
- the window that this location belongs topage
- the page that will become the enclosing page
-
getDefaultValue
Returns the JavaScript default value of this object. This is the JavaScript equivalent of a toString() in Java.- Specified by:
getDefaultValue
in interfaceorg.htmlunit.corejs.javascript.Scriptable
- Overrides:
getDefaultValue
in classHtmlUnitScriptable
- Parameters:
hint
- a hint as to the format of the default value (ignored in this case)- Returns:
- the default value
-
assign
Loads the new HTML document corresponding to the specified URL.- Parameters:
url
- the location of the new HTML document to load- Throws:
IOException
- if loading the specified location fails- See Also:
-
reload
Reloads the current page, possibly forcing retrieval from the server even if the browser cache contains the latest version of the document.- Parameters:
force
- iftrue
, force reload from server; otherwise, may reload from cache- Throws:
IOException
- if there is a problem reloading the page- See Also:
-
replace
Reloads the window using the specified URL via a postponed action.- Parameters:
url
- the new URL to use to reload the window- Throws:
IOException
- if loading the specified location fails- See Also:
-
jsToString
Returns the location URL.- Returns:
- the location URL
-
getHref
Returns the location URL.- Returns:
- the location URL
- See Also:
-
setHref
Sets the location URL to an entirely new value.- Parameters:
newLocation
- the new location URL- Throws:
IOException
- if loading the specified location fails- See Also:
-
getSearch
Returns the search portion of the location URL (the portion following the '?').- Returns:
- the search portion of the location URL
- See Also:
-
setSearch
Sets the search portion of the location URL (the portion following the '?').- Parameters:
search
- the new search portion of the location URL- Throws:
Exception
- if an error occurs- See Also:
-
getHash
Returns the hash portion of the location URL (the portion following the '#').- Returns:
- the hash portion of the location URL
- See Also:
-
getHash
-
setHash
Sets the hash portion of the location URL (the portion following the '#').- Parameters:
hash
- the new hash portion of the location URL- See Also:
-
setHash
Sets the hash portion of the location URL (the portion following the '#').- Parameters:
oldURL
- the old URLhash
- the new hash portion of the location URL
-
setHash
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Sets the hash portion of the location URL (the portion following the '#').- Parameters:
oldURL
- the old URLhash
- the new hash portion of the location URLtriggerHashChanged
- option to disable event triggering
-
decodeHash
-
getHostname
Returns the hostname portion of the location URL.- Returns:
- the hostname portion of the location URL
- See Also:
-
setHostname
Sets the hostname portion of the location URL.- Parameters:
hostname
- the new hostname portion of the location URL- Throws:
Exception
- if an error occurs- See Also:
-
getHost
Returns the host portion of the location URL (the '[hostname]:[port]' portion).- Returns:
- the host portion of the location URL
- See Also:
-
setHost
Sets the host portion of the location URL (the '[hostname]:[port]' portion).- Parameters:
host
- the new host portion of the location URL- Throws:
Exception
- if an error occurs- See Also:
-
getPathname
Returns the pathname portion of the location URL.- Returns:
- the pathname portion of the location URL
- See Also:
-
setPathname
Sets the pathname portion of the location URL.- Parameters:
pathname
- the new pathname portion of the location URL- Throws:
Exception
- if an error occurs- See Also:
-
getPort
Returns the port portion of the location URL.- Returns:
- the port portion of the location URL
- See Also:
-
setPort
Sets the port portion of the location URL.- Parameters:
port
- the new port portion of the location URL- Throws:
Exception
- if an error occurs- See Also:
-
getProtocol
Returns the protocol portion of the location URL, including the trailing ':'.- Returns:
- the protocol portion of the location URL, including the trailing ':'
- See Also:
-
setProtocol
Sets the protocol portion of the location URL.- Parameters:
protocol
- the new protocol portion of the location URL- Throws:
Exception
- if an error occurs- See Also:
-
getUrl
Returns this location's current URL.- Returns:
- this location's current URL
-
setUrl
Sets this location's URL, triggering a server hit and loading the resultant document into this location's window.- Parameters:
url
- This location's new URL- Throws:
IOException
- if there is a problem loading the new location
-
getOrigin
Returns theorigin
property.- Returns:
- the
origin
property
-