Search in sources :

Example 1 with UIEvent

use of com.gargoylesoftware.htmlunit.javascript.host.event.UIEvent in project htmlunit by HtmlUnit.

the class Document method setLocation.

/**
 * Sets the value of the {@code location} property. The location's default property is "href",
 * so setting "document.location='http://www.sf.net'" is equivalent to setting
 * "document.location.href='http://www.sf.net'".
 * @see <a href="http://msdn.microsoft.com/en-us/library/ms535866.aspx">MSDN documentation</a>
 * @param location the location to navigate to
 * @throws IOException when location loading fails
 */
@JsxSetter
public void setLocation(final String location) throws IOException {
    final Object event = getWindow().getEvent();
    if (event instanceof UIEvent) {
        final Object target = ((UIEvent) event).getTarget();
        if (target instanceof HTMLAnchorElement) {
            final String href = ((HTMLAnchorElement) target).getHref();
        }
    }
    window_.setLocation(location);
}
Also used : UIEvent(com.gargoylesoftware.htmlunit.javascript.host.event.UIEvent) HTMLAnchorElement(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLAnchorElement) ScriptableObject(net.sourceforge.htmlunit.corejs.javascript.ScriptableObject) FunctionObject(net.sourceforge.htmlunit.corejs.javascript.FunctionObject) JsxSetter(com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter)

Aggregations

JsxSetter (com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter)1 UIEvent (com.gargoylesoftware.htmlunit.javascript.host.event.UIEvent)1 HTMLAnchorElement (com.gargoylesoftware.htmlunit.javascript.host.html.HTMLAnchorElement)1 FunctionObject (net.sourceforge.htmlunit.corejs.javascript.FunctionObject)1 ScriptableObject (net.sourceforge.htmlunit.corejs.javascript.ScriptableObject)1