/** * Open this link in a new window, much as web browsers do when you shift-click a link or use the context * menu to open in a new window. * * It should be noted that even web browsers will sometimes not give the expected result when using this * method of following links. Links that have no real href and rely on JavaScript to do their work will * fail. * * @return the page opened by this link, nested in a new {@link com.gargoylesoftware.htmlunit.TopLevelWindow} * @throws MalformedURLException if the href could not be converted to a valid URL */ public final Page openLinkInNewWindow() throws MalformedURLException { final URL target = ((HtmlPage) getPage()).getFullyQualifiedUrl(getHrefAttribute()); final String windowName = "HtmlAnchor.openLinkInNewWindow() target"; final WebWindow newWindow = getPage().getWebClient().openWindow(target, windowName); return newWindow.getEnclosedPage(); }
/** * Returns this link's current URL. * @return this link's current URL * @throws MalformedURLException if an error occurs */ private URL getUrl() throws MalformedURLException { final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie(); return ((HtmlPage) anchor.getPage()).getFullyQualifiedUrl(anchor.getHrefAttribute()); }
/** * Returns this link's current URL. * @return this link's current URL * @throws MalformedURLException if an error occurs */ private URL getUrl() throws MalformedURLException { final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie(); return ((HtmlPage) anchor.getPage()).getFullyQualifiedUrl(anchor.getHrefAttribute()); }
/** * Open this link in a new window, much as web browsers do when you shift-click a link or use the context * menu to open in a new window. * * It should be noted that even web browsers will sometimes not give the expected result when using this * method of following links. Links that have no real href and rely on JavaScript to do their work will * fail. * * @return the page opened by this link, nested in a new {@link com.gargoylesoftware.htmlunit.TopLevelWindow} * @throws MalformedURLException if the href could not be converted to a valid URL */ public final Page openLinkInNewWindow() throws MalformedURLException { final URL target = ((HtmlPage) getPage()).getFullyQualifiedUrl(getHrefAttribute()); final String windowName = "HtmlAnchor.openLinkInNewWindow() target"; final WebWindow newWindow = getPage().getWebClient().openWindow(target, windowName); return newWindow.getEnclosedPage(); }
/** * Returns this link's current URL. * @return this link's current URL * @throws MalformedURLException if an error occurs */ private URL getUrl() throws MalformedURLException { final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie(); return ((HtmlPage) anchor.getPage()).getFullyQualifiedUrl(anchor.getHrefAttribute()); }
/** * Returns this link's current URL. * @return this link's current URL * @throws MalformedURLException if an error occurs */ private URL getUrl() throws MalformedURLException { final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie(); return ((HtmlPage) anchor.getPage()).getFullyQualifiedUrl(anchor.getHrefAttribute()); }
/** * Returns this link's current URL. * @return this link's current URL * @throws MalformedURLException if an error occurs */ private URL getUrl() throws MalformedURLException { final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie(); return ((HtmlPage) anchor.getPage()).getFullyQualifiedUrl(anchor.getHrefAttribute()); }
/** * Open this link in a new window, much as web browsers do when you shift-click a link or use the context * menu to open in a new window. * * It should be noted that even web browsers will sometimes not give the expected result when using this * method of following links. Links that have no real href and rely on JavaScript to do their work will * fail. * * @return the page opened by this link, nested in a new {@link com.gargoylesoftware.htmlunit.TopLevelWindow} * @throws MalformedURLException if the href could not be converted to a valid URL */ public final Page openLinkInNewWindow() throws MalformedURLException { final URL target = ((HtmlPage) getPage()).getFullyQualifiedUrl(getHrefAttribute()); final String windowName = "HtmlAnchor.openLinkInNewWindow() target"; final WebWindow newWindow = getPage().getWebClient().openWindow(target, windowName); return newWindow.getEnclosedPage(); } }
/** * Open this link in a new window, much as web browsers do when you shift-click a link or use the context * menu to open in a new window. * * It should be noted that even web browsers will sometimes not give the expected result when using this * method of following links. Links that have no real href and rely on JavaScript to do their work will * fail. * * @return the page opened by this link, nested in a new {@link com.gargoylesoftware.htmlunit.TopLevelWindow} * @throws MalformedURLException if the href could not be converted to a valid URL */ public final Page openLinkInNewWindow() throws MalformedURLException { final URL target = ((HtmlPage) getPage()).getFullyQualifiedUrl(getHrefAttribute()); final String windowName = "HtmlAnchor.openLinkInNewWindow() target"; final WebWindow newWindow = getPage().getWebClient().openWindow(target, windowName); return newWindow.getEnclosedPage(); } }
/** * Open this link in a new window, much as web browsers do when you shift-click a link or use the context * menu to open in a new window. * * It should be noted that even web browsers will sometimes not give the expected result when using this * method of following links. Links that have no real href and rely on JavaScript to do their work will * fail. * * @return the page opened by this link, nested in a new {@link com.gargoylesoftware.htmlunit.TopLevelWindow} * @throws MalformedURLException if the href could not be converted to a valid URL */ public final Page openLinkInNewWindow() throws MalformedURLException { final URL target = ((HtmlPage) getPage()).getFullyQualifiedUrl(getHrefAttribute()); final String windowName = "HtmlAnchor.openLinkInNewWindow() target"; final WebWindow newWindow = getPage().getWebClient().openWindow(target, windowName); return newWindow.getEnclosedPage(); } }
/** * This method will be called if there either wasn't an <tt>onclick</tt> handler, or * there was but the result of that handler was <tt>true</tt>. This is the default * behavior of clicking the element. For this anchor element, the default behavior is * to open the HREF page, or execute the HREF if it is a <tt>javascript:</tt> URL. * * @param defaultPage the default page to return if the action does not load a new page * @return the page that is currently loaded after execution of this method * @throws IOException if an IO error occurs */ @Override protected Page doClickAction(final Page defaultPage) throws IOException { final SgmlPage page = getPage(); final boolean onClickLoadedNewPageInCurrentWindow = defaultPage != page && defaultPage.getEnclosingWindow() == page.getEnclosingWindow(); if (onClickLoadedNewPageInCurrentWindow) { return defaultPage; } return doClickAction(defaultPage, ""); }
/** * This method will be called if there either wasn't an <tt>onclick</tt> handler, or * there was but the result of that handler was <tt>true</tt>. This is the default * behavior of clicking the element. For this anchor element, the default behavior is * to open the HREF page, or execute the HREF if it is a <tt>javascript:</tt> URL. * * @param defaultPage the default page to return if the action does not load a new page * @return the page that is currently loaded after execution of this method * @throws IOException if an IO error occurs */ @Override protected Page doClickAction(final Page defaultPage) throws IOException { final SgmlPage page = getPage(); final boolean onClickLoadedNewPageInCurrentWindow = defaultPage != page && defaultPage.getEnclosingWindow() == page.getEnclosingWindow(); if (onClickLoadedNewPageInCurrentWindow) { return defaultPage; } return doClickAction(defaultPage, ""); }
/** * This method will be called if there either wasn't an <tt>onclick</tt> handler, or * there was but the result of that handler was <tt>true</tt>. This is the default * behavior of clicking the element. For this anchor element, the default behavior is * to open the HREF page, or execute the HREF if it is a <tt>javascript:</tt> URL. * * @param defaultPage the default page to return if the action does not load a new page * @return the page that is currently loaded after execution of this method * @throws IOException if an IO error occurs */ @Override protected Page doClickAction(final Page defaultPage) throws IOException { final SgmlPage page = getPage(); final boolean onClickLoadedNewPageInCurrentWindow = defaultPage != page && defaultPage.getEnclosingWindow() == page.getEnclosingWindow(); if (onClickLoadedNewPageInCurrentWindow) { return defaultPage; } return doClickAction(defaultPage, ""); }
final String href = (getHrefAttribute() + hrefSuffix).trim(); if (LOG.isDebugEnabled()) { final String w = getPage().getEnclosingWindow().getName(); LOG.debug("do click action in window '" + w + "', using href '" + href + "'"); return; HtmlPage page = (HtmlPage) getPage(); if (StringUtils.startsWithIgnoreCase(href, JavaScriptURLConnection.JAVASCRIPT_PREFIX)) { final StringBuilder builder = new StringBuilder(href.length());
final String href = (getHrefAttribute() + hrefSuffix).trim(); if (LOG.isDebugEnabled()) { final String w = getPage().getEnclosingWindow().getName(); LOG.debug("do click action in window '" + w + "', using href '" + href + "'"); return; HtmlPage page = (HtmlPage) getPage(); if (StringUtils.startsWithIgnoreCase(href, JavaScriptURLConnection.JAVASCRIPT_PREFIX)) { final StringBuilder builder = new StringBuilder(href.length());
return defaultPage; final HtmlPage page = (HtmlPage) getPage(); if (TextUtil.startsWithIgnoreCase(href, JAVASCRIPT_PREFIX)) { return page.executeJavaScriptIfPossible(href, "javascript url", getStartLineNumber()).getNewPage();
return defaultPage; final HtmlPage page = (HtmlPage) getPage(); if (TextUtil.startsWithIgnoreCase(href, JAVASCRIPT_PREFIX)) { return page.executeJavaScriptIfPossible(href, "javascript url", getStartLineNumber()).getNewPage();
return defaultPage; final HtmlPage page = (HtmlPage) getPage(); if (TextUtil.startsWithIgnoreCase(href, JAVASCRIPT_PREFIX)) { return page.executeJavaScriptIfPossible(href, "javascript url", getStartLineNumber()).getNewPage();