• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java HTMLAnchorElement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.w3c.dom.html.HTMLAnchorElement的典型用法代码示例。如果您正苦于以下问题:Java HTMLAnchorElement类的具体用法?Java HTMLAnchorElement怎么用?Java HTMLAnchorElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HTMLAnchorElement类属于org.w3c.dom.html包,在下文中一共展示了HTMLAnchorElement类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: handleEvent

import org.w3c.dom.html.HTMLAnchorElement; //导入依赖的package包/类
@Override
public void handleEvent(Event event) {
    HTMLAnchorElement anchorElement = (HTMLAnchorElement) event.getCurrentTarget();
    String href = anchorElement.getHref();

    boolean done = false;
    try {
        if(Desktop.isDesktopSupported()) {
            openLinkInSystemBrowser(href);
            done = true;
        } else {
            LOGGER.warn("OS does not support desktop operations like browsing. Cannot open link '{}'.", href);
        }
    } catch(URISyntaxException | IOException e) {
        LOGGER.warn("OS does not support desktop operations like browsing. Failed open link '{}'.", href, e);
    }
    if(done) {
        event.preventDefault();
    }
}
 
开发者ID:headwirecom,项目名称:aem-ide-tooling-4-intellij,代码行数:21,代码来源:HyperlinkRedirectListener.java


示例2: handleEvent

import org.w3c.dom.html.HTMLAnchorElement; //导入依赖的package包/类
@Override public void handleEvent(Event event) {
    HTMLAnchorElement anchorElement = (HTMLAnchorElement) event.getCurrentTarget();
    String href = anchorElement.getHref();

    if (Desktop.isDesktopSupported()) {
        openLinkInSystemBrowser(href);
    } else {
        LOGGER.warning("OS does not support desktop operations like browsing. Cannot open link '{" + href + "}'.");
    }

    event.preventDefault();
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:13,代码来源:HyperlinkRedirectListener.java


示例3: handleEvent

import org.w3c.dom.html.HTMLAnchorElement; //导入依赖的package包/类
@Override
public void handleEvent(Event event) {
    HTMLAnchorElement anchorElement = (HTMLAnchorElement)event.getCurrentTarget();
    String href = anchorElement.getHref();

    if (isDesktopSupported()) {
        openLinkInSystemBrowser(href);
    } else {
        Log.warn(APPLICATION, "OS does not support desktop operations like browsing. Cannot open link '"+href+"'!");
    }

    event.preventDefault();
}
 
开发者ID:tbressler,项目名称:waterrower-workout,代码行数:14,代码来源:HyperlinkRedirectListener.java


示例4: redirectLinksToBrowser

import org.w3c.dom.html.HTMLAnchorElement; //导入依赖的package包/类
private static void redirectLinksToBrowser(WebEngine webEngine) {
    webEngine.getLoadWorker().stateProperty().addListener(
            (ov, oldState, newState) -> {
                // adjust link handling
                if (webEngine.getDocument() == null)
                    return;

                NodeList nodeList = webEngine.getDocument().getElementsByTagName("a");
                for (int i = 0; i < nodeList.getLength(); i++) {
                    Node node = nodeList.item(i);
                    EventTarget eventTarget = (EventTarget) node;

                    eventTarget.addEventListener("click", evt -> {
                        EventTarget target = evt.getCurrentTarget();
                        HTMLAnchorElement anchorElement = (HTMLAnchorElement) target;
                        String href = anchorElement.getHref();

                        //handle opening URL outside JavaFX WebView
                        try {
                            Desktop.getDesktop().browse(new URI(href));
                        } catch (IOException | URISyntaxException e) {
                            e.printStackTrace();
                        }
                        evt.preventDefault();
                    }, false);
                }
            });
}
 
开发者ID:holgerbrandl,项目名称:opencards,代码行数:29,代码来源:MdSlideManager.java


示例5: handleEvent

import org.w3c.dom.html.HTMLAnchorElement; //导入依赖的package包/类
@Override
public void handleEvent(Event evt) {
	final EventTarget target = evt.getCurrentTarget();
	final HTMLAnchorElement anchorElement = (HTMLAnchorElement) target;
	final String href = anchorElement.getHref();
	evt.preventDefault();
	JavaFXUtils.openWebpage(href);
}
 
开发者ID:Eldelshell,项目名称:JobHunter,代码行数:9,代码来源:WebViewOnClickListener.java


示例6: handleEvent

import org.w3c.dom.html.HTMLAnchorElement; //导入依赖的package包/类
@Override
public void handleEvent(Event evt) {
	EventTarget target = evt.getCurrentTarget();
	HTMLAnchorElement anchorElement = (HTMLAnchorElement) target;
	String url = anchorElement.getHref();

	// If the clicked link is downloadable
	// then we prevent the browser to follow the link
	// and instead we perform the download ourselves
	if (downloader.isDownloadable(url)) {
		downloader.download(url);
		evt.preventDefault();
	}
}
 
开发者ID:McFoggy,项目名称:fxnav-interceptor,代码行数:15,代码来源:AnchorClickEventListener.java


示例7: isLinkableElement

import org.w3c.dom.html.HTMLAnchorElement; //导入依赖的package包/类
/**
 * Tests if is passed Element an element which may be followed.
 * 
 * @param element Element to be tested.
 * @return True, if we can follow passed element.
 */
private static boolean isLinkableElement(Element element) {
  		if (element instanceof HTMLAnchorElement) {
  			return true;
  		} else if (element instanceof HTMLAreaElement) {
  			return true;
  		}
  		
  		return false;
}
 
开发者ID:ITman1,项目名称:ScriptBox,代码行数:16,代码来源:NavigationController.java


示例8: getTargetFromElement

import org.w3c.dom.html.HTMLAnchorElement; //导入依赖的package包/类
/**
 * Returns target attribute from the linkable element.
 * 
 * @param element Linkable element.
 * @return Target attribute.
 */
private static String getTargetFromElement(Element element) {
  		String targetAttr = null;
  		if (element instanceof HTMLAnchorElement) {
  			targetAttr = ((HTMLAnchorElement)element).getTarget();
  		} else if (element instanceof HTMLAreaElement) {
  			targetAttr = ((HTMLAreaElement)element).getTarget();
  		}
  		
  		return targetAttr;
}
 
开发者ID:ITman1,项目名称:ScriptBox,代码行数:17,代码来源:NavigationController.java


示例9: getHrefFromElement

import org.w3c.dom.html.HTMLAnchorElement; //导入依赖的package包/类
/**
 * Returns href attribute from the linkable element.
 * 
 * @param element Linkable element.
 * @return Href attribute.
 */
private static String getHrefFromElement(Element element) {
  		String targetAttr = null;
  		if (element instanceof HTMLAnchorElement) {
  			targetAttr = ((HTMLAnchorElement)element).getHref();
  		} else if (element instanceof HTMLAreaElement) {
  			targetAttr = ((HTMLAreaElement)element).getHref();
  		}
  		
  		return targetAttr;
}
 
开发者ID:ITman1,项目名称:ScriptBox,代码行数:17,代码来源:NavigationController.java


示例10: handleEvent

import org.w3c.dom.html.HTMLAnchorElement; //导入依赖的package包/类
@Override
public void handleEvent(Event event) {
    HTMLAnchorElement anchorElement = (HTMLAnchorElement) event.getCurrentTarget();
    String href = anchorElement.getHref();

    try {
        JabRefDesktop.openBrowser(href);
    } catch (IOException e) {
        LOGGER.error("Problem opening browser", e);
    }
    event.preventDefault();
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:13,代码来源:OpenHyperlinksInExternalBrowser.java


示例11: initFX

import org.w3c.dom.html.HTMLAnchorElement; //导入依赖的package包/类
private static void initFX(final JFXPanel fxPanel) {
    final WebView webView = new WebView();
    fxPanel.setScene(new Scene(webView));

    // Obtain the webEngine to navigate
    final WebEngine webEngine = webView.getEngine();
    webEngine.loadContent("Escapists Map Editor\n" +
            "Written by jselby\nhttp://redd.it/2wacp2\n\n" +
            "You don't have a map loaded currently - \nGo to File in the top left, and press a button there!\n" +
            "Loading...");
    webEngine.load("http://escapists.jselby.net/welcome/");

    webView.getEngine().getLoadWorker().stateProperty().addListener(new ChangeListener<Worker.State>() {
        @Override
        public void changed(ObservableValue<? extends Worker.State> observable,
                            Worker.State oldValue, Worker.State newValue) {
            if (newValue == Worker.State.SUCCEEDED) {
                final Document document = webEngine.getDocument();
                NodeList nodeList = document.getElementsByTagName("a");
                for (int i = 0; i < nodeList.getLength(); i++) {
                    Node node = nodeList.item(i);
                    EventTarget eventTarget = (EventTarget) node;
                    eventTarget.addEventListener("click", new org.w3c.dom.events.EventListener() {
                        @Override
                        public void handleEvent(Event evt) {
                            EventTarget target = evt.getCurrentTarget();
                            HTMLAnchorElement anchorElement = (HTMLAnchorElement) target;
                            String href = anchorElement.getHref();
                            Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
                            if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
                                try {
                                    desktop.browse(new URL(href).toURI());
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                            evt.preventDefault();
                        }
                    }, false);
                }
            }
        }
    });
}
 
开发者ID:j-selby,项目名称:EscapistsEditor,代码行数:45,代码来源:MapRendererComponent.java



注:本文中的org.w3c.dom.html.HTMLAnchorElement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MD5MD5CRC32CastagnoliFileChecksum类代码示例发布时间:2022-05-22
下一篇:
Java ProbeName类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap