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
-
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 Methodprivate static final Methodprivate static final Methodprivate static final Methodprivate static final Methodprivate static final Methodprivate static final Methodprivate static final Methodprivate static final Methodprivate StringThe 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.Logprivate static final Methodprivate static final Methodprivate static final Methodprivate static final Methodprivate static final Methodprivate static final Methodprivate static final Methodprivate static final Methodprivate static final Methodprivate static final Methodprivate static final Methodprivate static final Methodprivate static final Stringprivate WindowThe window which owns this location object.Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONSTFields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidLoads the new HTML document corresponding to the specified URL.private static StringdecodeHash(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 StringgetHash(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 theoriginproperty.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 URLgetUrl()Returns this location's current URL.voidinitialize(Window window, Page page) Initializes this Location.voidCreates an instance.Returns the location URL.voidreload(boolean force) Reloads the current page, possibly forcing retrieval from the server even if the browser cache contains the latest version of the document.voidReloads the window using the specified URL via a postponed action.voidSets the hash portion of the location URL (the portion following the '#').voidSets the hash portion of the location URL (the portion following the '#').voidINTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Sets the hash portion of the location URL (the portion following the '#').voidSets the host portion of the location URL (the '[hostname]:[port]' portion).voidsetHostname(String hostname) Sets the hostname portion of the location URL.voidSets the location URL to an entirely new value.voidsetPathname(String pathname) Sets the pathname portion of the location URL.voidSets the port portion of the location URL.voidsetProtocol(String protocol) Sets the protocol portion of the location URL.voidSets the search portion of the location URL (the portion following the '?').private voidSets this location's URL, triggering a server hit and loading the resultant document into this location's window.Methods inherited from class HtmlUnitScriptable
clone, equivalentValues, get, getBrowserVersion, getClassName, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, getWithPreemption, has, hasInstance, initParentScope, makeScriptableFor, put, setClassName, setDomNode, setDomNode, setParentScope, setupPromise, setupRejectedPromiseMethods 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
-
getDefaultValue
Returns the JavaScript default value of this object. This is the JavaScript equivalent of a toString() in Java.- Specified by:
getDefaultValuein interfaceorg.htmlunit.corejs.javascript.Scriptable- Overrides:
getDefaultValuein 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
-
getHref
-
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
-
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
-
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
-
getHost
Returns the host portion of the location URL (the '[hostname]:[port]' portion).- Returns:
- the host portion of the location URL
- See Also:
-
setHost
-
getPathname
Returns the pathname portion of the location URL.- Returns:
- the pathname portion of the location URL
- See Also:
-
setPathname
-
getPort
Returns the port portion of the location URL.- Returns:
- the port portion of the location URL
- See Also:
-
setPort
-
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
-
getUrl
-
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
-