Search in sources :

Example 1 with Location

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

the class WebClient method processOnlyHashChange.

private static void processOnlyHashChange(final WebWindow window, final URL urlWithOnlyHashChange) {
    final Page page = window.getEnclosedPage();
    final String oldURL = page.getUrl().toExternalForm();
    // update request url
    final WebRequest req = page.getWebResponse().getWebRequest();
    req.setUrl(urlWithOnlyHashChange);
    // update location.hash
    final Window jsWindow = window.getScriptableObject();
    if (null != jsWindow) {
        final Location location = jsWindow.getLocation();
        location.setHash(oldURL, urlWithOnlyHashChange.getRef());
    }
    // add to history
    window.getHistory().addPage(page);
}
Also used : Window(com.gargoylesoftware.htmlunit.javascript.host.Window) FrameWindow(com.gargoylesoftware.htmlunit.html.FrameWindow) XHtmlPage(com.gargoylesoftware.htmlunit.html.XHtmlPage) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) Location(com.gargoylesoftware.htmlunit.javascript.host.Location)

Aggregations

FrameWindow (com.gargoylesoftware.htmlunit.html.FrameWindow)1 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)1 XHtmlPage (com.gargoylesoftware.htmlunit.html.XHtmlPage)1 Location (com.gargoylesoftware.htmlunit.javascript.host.Location)1 Window (com.gargoylesoftware.htmlunit.javascript.host.Window)1