java.lang.Object
org.htmlunit.corejs.javascript.SlotMapOwner<org.htmlunit.corejs.javascript.Scriptable>
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.Scriptable>,org.htmlunit.corejs.javascript.debug.DebuggableObject,org.htmlunit.corejs.javascript.PropHolder<org.htmlunit.corejs.javascript.Scriptable>,org.htmlunit.corejs.javascript.Scriptable,org.htmlunit.corejs.javascript.SymbolScriptable
JavaScript host object for
Location.- Author:
- Mike Bowler, Michael Ottati, Marc Guillemot, Chris Erskine, Daniel Gredler, David K. Taylor, Ahmed Ashour, Ronald Brill, Frank Danek, Adam Afeltowicz, Atsushi Nakagawa, Lai Quang Duong, Kanoko Yamamoto
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.ScriptableObject.DescriptorInfo, org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator, org.htmlunit.corejs.javascript.ScriptableObject.LambdaGetterFunction, org.htmlunit.corejs.javascript.ScriptableObject.LambdaSetterFunction -
Field Summary
Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONSTFields inherited from class org.htmlunit.corejs.javascript.SlotMapOwner
isSealedFields 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.getDefaultValue(Class<?> hint) Returns the JavaScript default value of this object.getHash()Returns the hash portion of the location URL (the portion following the#).getHost()Returns the host portion of the location URL (the[hostname]:[port]portion).Returns the hostname portion of the location URL.getHref()Returns the full URL of the current page.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?).voidinitialize(org.htmlunit.corejs.javascript.VarScope scope, Window window, Page page) Initializes thisLocation.static LocationjsConstructor(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope, Object[] args, org.htmlunit.corejs.javascript.Function ctorObj, boolean inNewExpr) Creates an instance of this object.Returns the location URL as a string.voidreload(boolean force) Reloads the current page, optionally forcing retrieval from the server even if the browser cache contains the latest version of the document.voidLoads the document at the specified URL, replacing the current entry in the session history so that the previous page cannot be reached via the back button.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, navigating to the new page.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?).Methods inherited from class org.htmlunit.javascript.HtmlUnitScriptable
clone, equivalentValues, get, getBrowserVersion, getClassName, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getWindow, getWindow, getWindowOrWorkerGlobalScope, getWithPreemption, has, hasInstance, makeScriptableFor, put, setClassName, setDomNode, setDomNode, setupPromise, setupRejectedPromiseMethods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkNotSealed, checkPropertyChangeForSlot, checkPropertyChangeForSlot, checkPropertyDefinition, checkPropertyDefinition, checkSlotRemoval, defineBuiltinProperty, defineBuiltinProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureScriptableObjectButNotSymbol, ensureSymbolScriptable, ensureType, get, get, getAllIds, getAncestor, getArrayPrototype, getClassPrototype, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSuperProperty, getSuperProperty, getSuperProperty, getThis, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, hasProperty, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGenericDescriptor, isGetterOrSetter, isGetterOrSetter, isTrue, preventExtensions, put, put, putConst, putConstProperty, putConstProperty, putOwnProperty, putOwnProperty, putOwnProperty, putProperty, putProperty, putProperty, putProperty, putSuperProperty, putSuperProperty, putSuperProperty, querySlot, redefineProperty, redefineProperty, sameValue, sealObject, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, sizeMethods inherited from class org.htmlunit.corejs.javascript.SlotMapOwner
associateValue, checkNotSealed, copyAssociatedValue, createSlotMap, defineProperty, defineProperty, get, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getIds, has, has, isSealed, readMaps, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, writeMapsMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.htmlunit.corejs.javascript.Scriptable
get, getIds, has, hasMethods inherited from interface org.htmlunit.corejs.javascript.SymbolScriptable
get, has
-
Constructor Details
-
Location
public Location()
-
-
Method Details
-
jsConstructor
public static Location jsConstructor(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope, Object[] args, org.htmlunit.corejs.javascript.Function ctorObj, boolean inNewExpr) Creates an instance of this object.- Parameters:
cx- the current contextscope- the scopeargs- the constructor argumentsctorObj- the function objectinNewExpr- whether invoked vianew- Returns:
- the new
Locationinstance
-
initialize
Initializes thisLocation.- Parameters:
scope- the scopewindow- 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:
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 URL of the new HTML document to load- Throws:
IOException- if loading the specified location fails- See Also:
-
reload
Reloads the current page, optionally forcing retrieval from the server even if the browser cache contains the latest version of the document.- Parameters:
force- iftrue, force reload from the server; otherwise, the browser may reload from cache- Throws:
IOException- if there is a problem reloading the page- See Also:
-
replace
Loads the document at the specified URL, replacing the current entry in the session history so that the previous page cannot be reached via the back button.- Parameters:
url- the new URL to load- Throws:
IOException- if loading the specified location fails- See Also:
-
jsToString
Returns the location URL as a string.- Returns:
- the location URL
-
getHref
Returns the full URL of the current page.- Returns:
- the location URL
- See Also:
-
setHref
Sets the location URL to an entirely new value, navigating to the new page.- 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:
-
setHash
Sets the hash portion of the location URL (the portion following the#). This method does not cause a server hit.- 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
-
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, or an empty string if no port is specified
- 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
- 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:
-
getOrigin
Returns theoriginproperty.- Returns:
- the
originproperty
-