如何制作一个按钮链接到另一个html页面?
问题描述:
如何使一个按钮链接到另一个html页面?如何制作一个按钮链接到另一个html页面?
button.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
//this code has to redirect to another page within the project
}
答
问题被标记为GWT因此基于这...完全做到这一点的客户端,您可以使用com.google.gwt.user.client.Window
类。
Window.open(linkURL, "_self", "");
答
在gwt javadocs下查找Window类。 Window类中有一些静态成员。
open函数是相同在javascript:
Window.open(url, targetFrame, features)
在GWT,“_self”是当前的活动显示帧/窗口的名称。
位置替换,就像在javascript:
Window.location.replace(url)
显示警告或确认窗口:
Window.alert(msg)
Window.confirm(msg)
答
无需使用JS。从HTML5起,按钮支持formaction
属性,您可以在其中指定URL。
<form>
<button formaction="http://*.com">Go to *!</button>
</form>
参考:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-formaction