我需要实现以下方法:
public static Widget embedInHyperlink(String href, Widget content);
该方法需要创建一个小部件,该小部件将<a href="...">[content]</a>
在网站上呈现。
内容可以是一个复杂的窗口小部件,其中包含图像文本和其他窗口小部件。
我的第一个解决方案是创建一个FocusPanel
并添加一个ClickHandler
,但是用户无法[Ctrl]-单击小部件以在新的浏览器选项卡中将其打开。当我的内容窗口小部件未嵌入超链接中时,也无法右键单击和“在新选项卡中打开”或“另存为..”。
public class AnchorPanel extends SimplePanel {
public AnchorPanel(IsWidget content, String href, String target) {
super(DOM.createAnchor());
getElement().setAttribute("href", href);
getElement().setAttribute("target", target);
add(content);
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句