com.gargoylesoftware.htmlunit.javascript.host
Class Window

java.lang.Object
  extended by net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
      extended by com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
          extended by com.gargoylesoftware.htmlunit.javascript.host.Window
All Implemented Interfaces:
ScriptableWithFallbackGetter, Serializable, Cloneable, net.sourceforge.htmlunit.corejs.javascript.Callable, net.sourceforge.htmlunit.corejs.javascript.ConstProperties, net.sourceforge.htmlunit.corejs.javascript.debug.DebuggableObject, net.sourceforge.htmlunit.corejs.javascript.Function, net.sourceforge.htmlunit.corejs.javascript.Scriptable

public class Window
extends SimpleScriptable
implements ScriptableWithFallbackGetter, net.sourceforge.htmlunit.corejs.javascript.Function

A JavaScript object for a Window.

Version:
$Revision: 8518 $
Author:
Mike Bowler, Chen Jun, David K. Taylor, Christian Sell, Darrell DeBoer, Marc Guillemot, Dierk Koenig, Daniel Gredler, David D. Kilzer, Chris Erskine, Ahmed Ashour, Ronald Brill
See Also:
MSDN documentation, Serialized Form

Field Summary
 
Fields inherited from class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
 
Fields inherited from interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
NOT_FOUND
 
Constructor Summary
Window()
          Creates an instance.
 
Method Summary
 void addEventListener(String type, net.sourceforge.htmlunit.corejs.javascript.Function listener, boolean useCapture)
          Allows the registration of event listeners on the event target.
 void alert(Object message)
          The JavaScript function "alert()".
 String atob(String encodedData)
          Decodes a string of data which has been encoded using base-64 encoding..
 boolean attachEvent(String type, net.sourceforge.htmlunit.corejs.javascript.Function listener)
          Allows the registration of event listeners on the event target.
 void blur()
          Removes focus from this element.
 String btoa(String stringToEncode)
          Creates a base-64 encoded ASCII string from a string of binary data.
 Object call(net.sourceforge.htmlunit.corejs.javascript.Context cx, net.sourceforge.htmlunit.corejs.javascript.Scriptable scope, net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args)
          
 void captureEvents(String type)
          Does nothing special anymore...
 void clearInterval(int intervalID)
          Cancels the interval previously started using the setInterval method.
 void clearTimeout(int timeoutId)
          Cancels a time-out previously set with the setTimeout method.
 void close()
          Closes this window.
 void CollectGarbage()
          An undocumented IE function.
 boolean confirm(String message)
          The JavaScript function "confirm()".
 net.sourceforge.htmlunit.corejs.javascript.Scriptable construct(net.sourceforge.htmlunit.corejs.javascript.Context cx, net.sourceforge.htmlunit.corejs.javascript.Scriptable scope, Object[] args)
          
 Popup createPopup()
          Creates a popup window.
 void detachEvent(String type, net.sourceforge.htmlunit.corejs.javascript.Function listener)
          Allows the removal of event listeners on the event target.
 boolean dispatchEvent(Event event)
          Dispatches an event into the event system (standards-conformant browsers only).
 void dump(String message)
          Prints messages to the console.
 void execScript(String script, Object language)
          Executes the specified script code as long as the language is JavaScript or JScript.
 ScriptResult executeEvent(Event event)
          Executes the event on this object only (needed for instance for onload on (i)frame tags).
protected  ScriptResult executeEvent(Event event, EventListenersContainer eventListenersContainer)
          INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Executes the event on this window only.
 void focus()
          Sets the focus to this element.
 Object get(int index, net.sourceforge.htmlunit.corejs.javascript.Scriptable start)
          
 Object get(String name, net.sourceforge.htmlunit.corejs.javascript.Scriptable start)
          Gets a named property from the object.
 OfflineResourceList getApplicationCache()
          Returns the application cache.
 Navigator getClientInformation()
          Returns the JavaScript property "clientInformation".
 ClipboardData getClipboardData()
          Returns the JavaScript property "clipboardData".
 boolean getClosed()
          Indicates if this window is closed.
 ComputedCSSStyleDeclaration getComputedStyle(Element element, String pseudo)
          Returns computed style of the element.
 net.sourceforge.htmlunit.corejs.javascript.ScriptableObject getConsole()
          Returns the console property.
 Object getControllers()
          Gets the controllers.
 Event getCurrentEvent()
          Returns the current event (used internally regardless of the emulation mode).
 DocumentProxy getDocument_js()
          Returns the JavaScript property "document".
 Document getDocument()
          Returns the window's current document.
 Object getEvent()
          Returns the current event (used by JavaScript only when emulating IE).
 EventListenersContainer getEventListenersContainer()
          Gets the container for event listeners.
 External getExternal()
          Returns the "external" property.
 Object getFrameElement()
          Returns the (i)frame in which the window is contained.
 WindowProxy getFrames_js()
          Returns the value of the frames property.
 StorageList getGlobalStorage()
          Returns the globalStorage property.
 History getHistory()
          Returns the "history" property.
 int getInnerHeight()
          Returns the innerHeight.
 int getInnerWidth()
          Returns the innerWidth.
 int getLength()
          Returns the number of frames contained by this window.
 Storage getLocalStorage()
          Returns the localStorage property.
 Location getLocation()
          Returns the location property.
 int getMozInnerScreenX()
          Returns the value of "mozInnerScreenX" property.
 int getMozInnerScreenY()
          Returns the value of "mozInnerScreenY" property.
 int getMozPaintCount()
          Returns the value of "mozPaintCount" property.
 String getName()
          Returns the value of the window's name property.
 Navigator getNavigator()
          Returns the JavaScript property "navigator".
 Netscape getNetscape()
          Returns the value of "netscape" property.
 Object getOnbeforeunload()
          Returns the value of the window's onbeforeunload property.
 Object getOnchange()
          Getter for the onchange event handler.
 Object getOnclick()
          Returns the onclick property (caution this is not necessary a function if something else has been set).
 Object getOndblclick()
          Returns the ondblclick property (caution this is not necessary a function if something else has been set).
 Object getOnerror()
          Returns the value of the window's onerror property.
 Object getOnhashchange()
          Returns the onhashchange property (caution this is not necessary a function if something else has been set).
 Object getOnload()
          Returns the onload property.
 Object getOpener()
          Returns the value of the opener property.
 int getOuterHeight()
          Returns the outer height.
 int getOuterWidth()
          Returns the outerWidth.
 int getPageXOffset()
          Returns the value of "pageXOffset" property.
 int getPageYOffset()
          Returns the value of "pageYOffset" property.
 WindowProxy getParent()
          Returns the value of the parent property.
 net.sourceforge.htmlunit.corejs.javascript.Scriptable getPrototype(Class<? extends SimpleScriptable> jsClass)
          Returns the prototype object corresponding to the specified HtmlUnit class inside the window scope.
static WindowProxy getProxy(WebWindow w)
          Returns the proxy for the specified window.
 Screen getScreen()
          Returns the "screen" property.
 int getScrollX()
          Returns the value of "scrollX" property.
 int getScrollY()
          Returns the value of "scrollY" property.
 Selection getSelection()
          Returns the current selection.
 Selection getSelectionImpl()
          Returns the current selection.
 WindowProxy getSelf()
          Returns the "self" property.
 Storage getSessionStorage()
          Returns the sessionStorage property.
 String getStatus()
          Returns the text from the status line.
 Storage getStorage(StorageHolder.Type storageType)
          Gets the storage of the specified type.
 Object getTop()
          Returns the value of the top property.
 WebWindow getWebWindow()
          Returns the WebWindow associated with this Window.
 WindowProxy getWindow_js()
          Returns the window property.
 Object getWithFallback(String name)
          Fallback called when no configured property is found with the given name on the Scriptable object.
 void initialize()
          Initializes the object.
 void initialize(Page enclosedPage)
          Initialize the object.
 void initialize(WebWindow webWindow)
          Initializes this window.
 boolean isConst(String name)
           Used to allow re-declaration of constants (eg: "var undefined;").
 void moveBy(int x, int y)
          Does nothing.
 void moveTo(int x, int y)
          Does nothing.
 WindowProxy open(Object url, Object name, Object features, Object replace)
          Opens a new window.
 void postMessage(String message, String targetOrigin)
          Posts a message.
 void print()
          Prints the current page.
 String prompt(String message)
          The JavaScript function "prompt()".
 void removeEventListener(String type, net.sourceforge.htmlunit.corejs.javascript.Function listener, boolean useCapture)
          Allows the removal of event listeners on the event target.
 void resizeBy(int width, int height)
          Does nothing.
 void resizeTo(int width, int height)
          Does nothing.
 String ScriptEngine()
          Gets the name of the scripting engine.
 int ScriptEngineBuildVersion()
          Gets the build version of the scripting engine.
 int ScriptEngineMajorVersion()
          Gets the major version of the scripting engine.
 int ScriptEngineMinorVersion()
          Gets the minor version of the scripting engine.
 void scroll(int x, int y)
          Scrolls to the specified location on the page.
 void scrollBy(int x, int y)
          Scrolls the window content the specified distance.
 void scrollByLines(int lines)
          Scrolls the window content down by the specified number of lines.
 void scrollByPages(int pages)
          Scrolls the window content down by the specified number of pages.
 void scrollTo(int x, int y)
          Scrolls to the specified location on the page.
 void setConsole(net.sourceforge.htmlunit.corejs.javascript.ScriptableObject console)
          Sets the console.
 void setControllers(Object value)
          Sets the controllers.
 int setInterval(Object code, int timeout, Object language)
          Sets a chunk of JavaScript to be invoked each time a specified number of milliseconds has elapsed.
 void setLocation(String newLocation)
          Sets the location property.
 void setName(String name)
          Sets the value of the window's name property.
 void setOnbeforeunload(Object onbeforeunload)
          Sets the value of the window's onbeforeunload property.
 void setOnchange(Object onchange)
          Setter for the onchange event handler.
 void setOnclick(Object newOnload)
          Sets the value of the onclick event handler.
 void setOndblclick(Object newHandler)
          Sets the value of the ondblclick event handler.
 void setOnerror(Object onerror)
          Sets the value of the window's onerror property.
 void setOnhashchange(Object newHandler)
          Sets the value of the onhashchange event handler.
 void setOnload(Object newOnload)
          Sets the value of the onload event handler.
 void setOpener(Object newValue)
          Sets the opener property.
 void setPrototypes(Map<Class<? extends SimpleScriptable>,net.sourceforge.htmlunit.corejs.javascript.Scriptable> map)
          Sets the prototypes for HtmlUnit host classes.
 void setStatus(String message)
          Sets the text from the status line.
 int setTimeout(Object code, int timeout, Object language)
          Sets a chunk of JavaScript to be invoked at some specified time later.
 void setTop(Object o)
          Sets the value of the top property.
 Object showModalDialog(String url, Object arguments, String features)
          Creates a modal dialog box that displays the specified HTML document.
 Object showModelessDialog(String url, Object arguments, String features)
          Creates a modeless dialog box that displays the specified HTML document.
 void stop()
          Should implement the stop() function on the window object.
 void triggerOnError(ScriptException e)
          Triggers the onerror handler, if one has been set.
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
clone, defineFunctionProperties, defineProperty, equivalentValues, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getScriptableFor, getStartingScope, getTransformerScriptableFor, getWindow, getWindow, getWithPreemption, hasInstance, initParentScope, isReadOnlySettable, makeScriptableFor, setCaseSensitive, setDomNode, setDomNode, setHtmlElement, setParentScope
 
Methods inherited from class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, isAccessorDescriptor, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setPrototype, size
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
delete, delete, getClassName, getDefaultValue, getIds, getParentScope, getPrototype, has, has, hasInstance, put, put, setParentScope, setPrototype
 

Constructor Detail

Window

public Window()
Creates an instance.

Method Detail

getPrototype

public net.sourceforge.htmlunit.corejs.javascript.Scriptable getPrototype(Class<? extends SimpleScriptable> jsClass)
Returns the prototype object corresponding to the specified HtmlUnit class inside the window scope.

Overrides:
getPrototype in class SimpleScriptable
Parameters:
jsClass - the class whose prototype is to be returned
Returns:
the prototype object corresponding to the specified class inside the specified scope

setPrototypes

public void setPrototypes(Map<Class<? extends SimpleScriptable>,net.sourceforge.htmlunit.corejs.javascript.Scriptable> map)
Sets the prototypes for HtmlUnit host classes.

Parameters:
map - a Map of (Class, Scriptable)

alert

public void alert(Object message)
The JavaScript function "alert()".

Parameters:
message - the message

btoa

public String btoa(String stringToEncode)
Creates a base-64 encoded ASCII string from a string of binary data.

Parameters:
stringToEncode - string to encode
Returns:
the encoded string

atob

public String atob(String encodedData)
Decodes a string of data which has been encoded using base-64 encoding..

Parameters:
encodedData - the encoded string
Returns:
the decoded value

confirm

public boolean confirm(String message)
The JavaScript function "confirm()".

Parameters:
message - the message
Returns:
true if ok was pressed, false if cancel was pressed

prompt

public String prompt(String message)
The JavaScript function "prompt()".

Parameters:
message - the message
Returns:
true if ok was pressed, false if cancel was pressed

getDocument_js

public DocumentProxy getDocument_js()
Returns the JavaScript property "document".

Returns:
the document

getDocument

public Document getDocument()
Returns the window's current document.

Returns:
the window's current document

getApplicationCache

public OfflineResourceList getApplicationCache()
Returns the application cache.

Returns:
the application cache

getEvent

public Object getEvent()
Returns the current event (used by JavaScript only when emulating IE).

Returns:
the current event, or null if no event is currently available

getCurrentEvent

public Event getCurrentEvent()
Returns the current event (used internally regardless of the emulation mode).

Returns:
the current event, or null if no event is currently available

open

public WindowProxy open(Object url,
                        Object name,
                        Object features,
                        Object replace)
Opens a new window.

Parameters:
url - when a new document is opened, url is a String that specifies a MIME type for the document. When a new window is opened, url is a String that specifies the URL to render in the new window
name - the name
features - the features
replace - whether to replace in the history list or no
Returns:
the newly opened window, or null if popup windows have been disabled
See Also:
WebClientOptions.isPopupBlockerEnabled(), MSDN documentation

createPopup

public Popup createPopup()
Creates a popup window.

Returns:
the created popup
See Also:
MSDN documentation

setTimeout

public int setTimeout(Object code,
                      int timeout,
                      Object language)
Sets a chunk of JavaScript to be invoked at some specified time later. The invocation occurs only if the window is opened after the delay and does not contain an other page than the one that originated the setTimeout.

Parameters:
code - specifies the function pointer or string that indicates the code to be executed when the specified interval has elapsed
timeout - specifies the number of milliseconds
language - specifies language
Returns:
the id of the created timer

clearTimeout

public void clearTimeout(int timeoutId)
Cancels a time-out previously set with the setTimeout method.

Parameters:
timeoutId - identifier for the timeout to clear (returned by setTimeout)

getNavigator

public Navigator getNavigator()
Returns the JavaScript property "navigator".

Returns:
the navigator

getClientInformation

public Navigator getClientInformation()
Returns the JavaScript property "clientInformation".

Returns:
the client information

getClipboardData

public ClipboardData getClipboardData()
Returns the JavaScript property "clipboardData".

Returns:
the ClipboardData

getWindow_js

public WindowProxy getWindow_js()
Returns the window property. This is a synonym for "self".

Returns:
the window property (a reference to this)

getSelf

public WindowProxy getSelf()
Returns the "self" property.

Returns:
this

getLocalStorage

public Storage getLocalStorage()
Returns the localStorage property.

Returns:
the localStorage property

getSessionStorage

public Storage getSessionStorage()
Returns the sessionStorage property.

Returns:
the sessionStorage property

getStorage

public Storage getStorage(StorageHolder.Type storageType)
Gets the storage of the specified type.

Parameters:
storageType - the type
Returns:
the storage

getGlobalStorage

public StorageList getGlobalStorage()
Returns the globalStorage property.

Returns:
the globalStorage property

getLocation

public Location getLocation()
Returns the location property.

Returns:
the location property

setLocation

public void setLocation(String newLocation)
                 throws IOException
Sets the location property. This will cause a reload of the window.

Parameters:
newLocation - the URL of the new content
Throws:
IOException - when location loading fails

getConsole

public net.sourceforge.htmlunit.corejs.javascript.ScriptableObject getConsole()
Returns the console property.

Returns:
the console property

setConsole

public void setConsole(net.sourceforge.htmlunit.corejs.javascript.ScriptableObject console)
Sets the console.

Parameters:
console - the console

dump

public void dump(String message)
Prints messages to the console.

Parameters:
message - the message to log

getScreen

public Screen getScreen()
Returns the "screen" property.

Returns:
the screen property

getHistory

public History getHistory()
Returns the "history" property.

Returns:
the "history" property

getExternal

public External getExternal()
Returns the "external" property.

Returns:
the "external" property

initialize

public void initialize(WebWindow webWindow)
Initializes this window.

Parameters:
webWindow - the web window corresponding to this window

initialize

public void initialize(Page enclosedPage)
Initialize the object.

Parameters:
enclosedPage - the page containing the JavaScript

initialize

public void initialize()
Initializes the object. Only called for Windows with no contents.


getTop

public Object getTop()
Returns the value of the top property.

Returns:
the value of "top"

setTop

public void setTop(Object o)
Sets the value of the top property.

Parameters:
o - the new value

getParent

public WindowProxy getParent()
Returns the value of the parent property.

Returns:
the value of window.parent

getOpener

public Object getOpener()
Returns the value of the opener property.

Returns:
the value of window.opener, null for a top level window

setOpener

public void setOpener(Object newValue)
Sets the opener property.

Parameters:
newValue - the new value

getFrameElement

public Object getFrameElement()
Returns the (i)frame in which the window is contained.

Returns:
null for a top level window

getFrames_js

public WindowProxy getFrames_js()
Returns the value of the frames property.

Returns:
the value of the frames property

getLength

public int getLength()
Returns the number of frames contained by this window.

Returns:
the number of frames contained by this window

getWebWindow

public WebWindow getWebWindow()
Returns the WebWindow associated with this Window.

Returns:
the WebWindow

focus

public void focus()
Sets the focus to this element.


blur

public void blur()
Removes focus from this element.


close

public void close()
Closes this window.


getClosed

public boolean getClosed()
Indicates if this window is closed.

Returns:
true if this window is closed

moveTo

public void moveTo(int x,
                   int y)
Does nothing.

Parameters:
x - the horizontal position
y - the vertical position

moveBy

public void moveBy(int x,
                   int y)
Does nothing.

Parameters:
x - the horizontal position
y - the vertical position

resizeBy

public void resizeBy(int width,
                     int height)
Does nothing.

Parameters:
width - the width offset
height - the height offset

resizeTo

public void resizeTo(int width,
                     int height)
Does nothing.

Parameters:
width - the width of the Window in pixel after resize
height - the height of the Window in pixel after resize

scroll

public void scroll(int x,
                   int y)
Scrolls to the specified location on the page.

Parameters:
x - the horizontal position to scroll to
y - the vertical position to scroll to

scrollBy

public void scrollBy(int x,
                     int y)
Scrolls the window content the specified distance.

Parameters:
x - the horizontal distance to scroll by
y - the vertical distance to scroll by

scrollByLines

public void scrollByLines(int lines)
Scrolls the window content down by the specified number of lines.

Parameters:
lines - the number of lines to scroll down

scrollByPages

public void scrollByPages(int pages)
Scrolls the window content down by the specified number of pages.

Parameters:
pages - the number of pages to scroll down

scrollTo

public void scrollTo(int x,
                     int y)
Scrolls to the specified location on the page.

Parameters:
x - the horizontal position to scroll to
y - the vertical position to scroll to

setOnload

public void setOnload(Object newOnload)
Sets the value of the onload event handler.

Parameters:
newOnload - the new handler

setOnclick

public void setOnclick(Object newOnload)
Sets the value of the onclick event handler.

Parameters:
newOnload - the new handler

getOnclick

public Object getOnclick()
Returns the onclick property (caution this is not necessary a function if something else has been set).

Returns:
the onclick property

setOndblclick

public void setOndblclick(Object newHandler)
Sets the value of the ondblclick event handler.

Parameters:
newHandler - the new handler

getOndblclick

public Object getOndblclick()
Returns the ondblclick property (caution this is not necessary a function if something else has been set).

Returns:
the ondblclick property

getOnload

public Object getOnload()
Returns the onload property. Note that this is not necessarily a function if something else has been set.

Returns:
the onload property

getOnhashchange

public Object getOnhashchange()
Returns the onhashchange property (caution this is not necessary a function if something else has been set).

Returns:
the onhashchange property

setOnhashchange

public void setOnhashchange(Object newHandler)
Sets the value of the onhashchange event handler.

Parameters:
newHandler - the new handler

getEventListenersContainer

public EventListenersContainer getEventListenersContainer()
Gets the container for event listeners.

Returns:
the container (newly created if needed)

attachEvent

public boolean attachEvent(String type,
                           net.sourceforge.htmlunit.corejs.javascript.Function listener)
Allows the registration of event listeners on the event target.

Parameters:
type - the event type to listen for (like "load")
listener - the event listener
Returns:
true if the listener has been added
See Also:
MSDN documentation

addEventListener

public void addEventListener(String type,
                             net.sourceforge.htmlunit.corejs.javascript.Function listener,
                             boolean useCapture)
Allows the registration of event listeners on the event target.

Parameters:
type - the event type to listen for (like "onload")
listener - the event listener
useCapture - If true, indicates that the user wishes to initiate capture (not yet implemented)
See Also:
Mozilla documentation

detachEvent

public void detachEvent(String type,
                        net.sourceforge.htmlunit.corejs.javascript.Function listener)
Allows the removal of event listeners on the event target.

Parameters:
type - the event type to listen for (like "onload")
listener - the event listener
See Also:
MSDN documentation

removeEventListener

public void removeEventListener(String type,
                                net.sourceforge.htmlunit.corejs.javascript.Function listener,
                                boolean useCapture)
Allows the removal of event listeners on the event target.

Parameters:
type - the event type to listen for (like "load")
listener - the event listener
useCapture - If true, indicates that the user wishes to initiate capture (not yet implemented)
See Also:
Mozilla documentation

getName

public String getName()
Returns the value of the window's name property.

Returns:
the value of the window's name property

setName

public void setName(String name)
Sets the value of the window's name property.

Parameters:
name - the value of the window's name property

getOnbeforeunload

public Object getOnbeforeunload()
Returns the value of the window's onbeforeunload property.

Returns:
the value of the window's onbeforeunload property

setOnbeforeunload

public void setOnbeforeunload(Object onbeforeunload)
Sets the value of the window's onbeforeunload property.

Parameters:
onbeforeunload - the value of the window's onbeforeunload property

getOnerror

public Object getOnerror()
Returns the value of the window's onerror property.

Returns:
the value of the window's onerror property

setOnerror

public void setOnerror(Object onerror)
Sets the value of the window's onerror property.

Parameters:
onerror - the value of the window's onerror property

triggerOnError

public void triggerOnError(ScriptException e)
Triggers the onerror handler, if one has been set.

Parameters:
e - the error that needs to be reported

call

public Object call(net.sourceforge.htmlunit.corejs.javascript.Context cx,
                   net.sourceforge.htmlunit.corejs.javascript.Scriptable scope,
                   net.sourceforge.htmlunit.corejs.javascript.Scriptable thisObj,
                   Object[] args)

Specified by:
call in interface net.sourceforge.htmlunit.corejs.javascript.Callable
Specified by:
call in interface net.sourceforge.htmlunit.corejs.javascript.Function

construct

public net.sourceforge.htmlunit.corejs.javascript.Scriptable construct(net.sourceforge.htmlunit.corejs.javascript.Context cx,
                                                                       net.sourceforge.htmlunit.corejs.javascript.Scriptable scope,
                                                                       Object[] args)

Specified by:
construct in interface net.sourceforge.htmlunit.corejs.javascript.Function

getWithFallback

public Object getWithFallback(String name)
Fallback called when no configured property is found with the given name on the Scriptable object.

Specified by:
getWithFallback in interface ScriptableWithFallbackGetter
Parameters:
name - the name of the requested property
Returns:
the object value, Scriptable.NOT_FOUND if nothing is found

get

public Object get(int index,
                  net.sourceforge.htmlunit.corejs.javascript.Scriptable start)

Specified by:
get in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
Overrides:
get in class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject

get

public Object get(String name,
                  net.sourceforge.htmlunit.corejs.javascript.Scriptable start)
Gets a named property from the object. Normally HtmlUnit objects don't need to overwrite this method as properties are defined on the prototypes from the XML configuration. In some cases where "content" of object has priority compared to the properties consider using utility SimpleScriptable.getWithPreemption(String). For fallback case just implement ScriptableWithFallbackGetter.

Specified by:
get in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
Overrides:
get in class SimpleScriptable

getProxy

public static WindowProxy getProxy(WebWindow w)
Returns the proxy for the specified window.

Parameters:
w - the window whose proxy is to be returned
Returns:
the proxy for the specified window

execScript

public void execScript(String script,
                       Object language)
Executes the specified script code as long as the language is JavaScript or JScript. Does nothing if the language specified is VBScript. Note: MSDN doc says that the function returns null but in fact this is undefined.

Parameters:
script - the script code to execute
language - the language of the specified code ("JavaScript", "JScript" or "VBScript")
See Also:
MSDN documentation

getStatus

public String getStatus()
Returns the text from the status line.

Returns:
the status line text

setStatus

public void setStatus(String message)
Sets the text from the status line.

Parameters:
message - the status line text

setInterval

public int setInterval(Object code,
                       int timeout,
                       Object language)
Sets a chunk of JavaScript to be invoked each time a specified number of milliseconds has elapsed.

Parameters:
code - specifies the function pointer or string that indicates the code to be executed when the specified interval has elapsed
timeout - specifies the number of milliseconds
language - specifies language
Returns:
the id of the created interval
See Also:
MSDN documentation

clearInterval

public void clearInterval(int intervalID)
Cancels the interval previously started using the setInterval method. Current implementation does nothing.

Parameters:
intervalID - specifies the interval to cancel as returned by the setInterval method
See Also:
MSDN documentation

getInnerWidth

public int getInnerWidth()
Returns the innerWidth.

Returns:
a dummy value
See Also:
Mozilla doc

getOuterWidth

public int getOuterWidth()
Returns the outerWidth.

Returns:
a dummy value
See Also:
Mozilla doc

getInnerHeight

public int getInnerHeight()
Returns the innerHeight.

Returns:
a dummy value
See Also:
Mozilla doc

getOuterHeight

public int getOuterHeight()
Returns the outer height.

Returns:
a dummy value
See Also:
Mozilla doc

print

public void print()
Prints the current page. The current implementation does nothing.

See Also:
Mozilla documentation, MSDN documentation

captureEvents

public void captureEvents(String type)
Does nothing special anymore... just like FF.

Parameters:
type - the type of events to capture
See Also:
Document.captureEvents(String)

CollectGarbage

public void CollectGarbage()
An undocumented IE function.


getComputedStyle

public ComputedCSSStyleDeclaration getComputedStyle(Element element,
                                                    String pseudo)
Returns computed style of the element. Computed style represents the final computed values of all CSS properties for the element. This method's return value is of the same type as that of element.style, but the value returned by this method is read-only.

Parameters:
element - the element
pseudo - a string specifying the pseudo-element to match (may be null)
Returns:
the computed style

getSelection

public Selection getSelection()
Returns the current selection.

Returns:
the current selection

getSelectionImpl

public Selection getSelectionImpl()
Returns the current selection.

Returns:
the current selection

showModalDialog

public Object showModalDialog(String url,
                              Object arguments,
                              String features)
Creates a modal dialog box that displays the specified HTML document.

Parameters:
url - the URL of the document to load and display
arguments - object to be made available via window.dialogArguments in the dialog window
features - string that specifies the window ornaments for the dialog window
Returns:
the value of the returnValue property as set by the modal dialog's window
See Also:
MSDN Documentation, Mozilla Documentation

showModelessDialog

public Object showModelessDialog(String url,
                                 Object arguments,
                                 String features)
Creates a modeless dialog box that displays the specified HTML document.

Parameters:
url - the URL of the document to load and display
arguments - object to be made available via window.dialogArguments in the dialog window
features - string that specifies the window ornaments for the dialog window
Returns:
a reference to the new window object created for the modeless dialog
See Also:
MSDN Documentation

getControllers

public Object getControllers()
Gets the controllers. The result doesn't currently matter but it is important to return an object as some JavaScript libraries check it.

Returns:
some object
See Also:
Mozilla documentation

setControllers

public void setControllers(Object value)
Sets the controllers.

Parameters:
value - the new value

getMozInnerScreenX

public int getMozInnerScreenX()
Returns the value of "mozInnerScreenX" property.

Returns:
the value of "mozInnerScreenX" property

getMozInnerScreenY

public int getMozInnerScreenY()
Returns the value of "mozInnerScreenY" property.

Returns:
the value of "mozInnerScreenY" property

getMozPaintCount

public int getMozPaintCount()
Returns the value of "mozPaintCount" property.

Returns:
the value of "mozPaintCount" property

ScriptEngine

public String ScriptEngine()
Gets the name of the scripting engine.

Returns:
"JScript"
See Also:
MSDN doc

ScriptEngineBuildVersion

public int ScriptEngineBuildVersion()
Gets the build version of the scripting engine.

Returns:
the build version
See Also:
MSDN doc

ScriptEngineMajorVersion

public int ScriptEngineMajorVersion()
Gets the major version of the scripting engine.

Returns:
the major version
See Also:
MSDN doc

ScriptEngineMinorVersion

public int ScriptEngineMinorVersion()
Gets the minor version of the scripting engine.

Returns:
the minor version
See Also:
MSDN doc

stop

public void stop()
Should implement the stop() function on the window object. (currently empty implementation)

See Also:
window.stop

getPageXOffset

public int getPageXOffset()
Returns the value of "pageXOffset" property.

Returns:
the value of "pageXOffset" property

getPageYOffset

public int getPageYOffset()
Returns the value of "pageYOffset" property.

Returns:
the value of "pageYOffset" property

getScrollX

public int getScrollX()
Returns the value of "scrollX" property.

Returns:
the value of "scrollX" property

getScrollY

public int getScrollY()
Returns the value of "scrollY" property.

Returns:
the value of "scrollY" property

getNetscape

public Netscape getNetscape()
Returns the value of "netscape" property.

Returns:
the value of "netscape" property

executeEvent

public ScriptResult executeEvent(Event event)
Executes the event on this object only (needed for instance for onload on (i)frame tags).

Parameters:
event - the event
Returns:
the result

executeEvent

protected ScriptResult executeEvent(Event event,
                                    EventListenersContainer eventListenersContainer)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Executes the event on this window only. Internal helper to share the impl with Node.java.

Parameters:
event - the event
eventListenersContainer - the container with the listeners
Returns:
the result

isConst

public boolean isConst(String name)
Used to allow re-declaration of constants (eg: "var undefined;").

Specified by:
isConst in interface net.sourceforge.htmlunit.corejs.javascript.ConstProperties
Overrides:
isConst in class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
See Also:
com.gargoylesoftware.htmlunit.javascript.NativeGlobalTest

dispatchEvent

public boolean dispatchEvent(Event event)
Dispatches an event into the event system (standards-conformant browsers only). See the Gecko DOM reference for more information.

Parameters:
event - the event to be dispatched
Returns:
false if at least one of the event handlers which handled the event called preventDefault; true otherwise

getOnchange

public Object getOnchange()
Getter for the onchange event handler.

Returns:
the handler

setOnchange

public void setOnchange(Object onchange)
Setter for the onchange event handler.

Parameters:
onchange - the handler

postMessage

public void postMessage(String message,
                        String targetOrigin)
Posts a message.

Parameters:
message - the object passed to the window
targetOrigin - the origin this window must be for the event to be dispatched
See Also:
MDN documentation


Copyright © 2002–2013 Gargoyle Software Inc.. All rights reserved.