GWT可点击的链接(锚点)没有href [英] GWT clickable link (anchor) without href

查看:115
本文介绍了GWT可点击的链接(锚点)没有href的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在GWT中创建一个可以点击的链接(锚点),它的 ClickEvent 可以被处理,而同时这个锚点不会重新加载页面。这基本上意味着不能设置 href

I'm trying to create a link (anchor) in GWT that can be clicked and it's ClickEvent can be processed, while at the same time this anchor wouldn't reload the page. This basically means that a href must not be set.

在javascript中,这样做是这样的:

In javascript this is done like this:

<a href="javascript:handleAnchorClick();">Link</a> 

或与

or with

<a href="#" onclick="return handleAnchorClick()">Link</a>  

其中 handleAnchorClick()返回false。

在GWT中实现此目的的最佳方法是什么?

What would be the best way to achieve this in GWT?

推荐答案

使用tha 锚元素,并将其称为 addClickListener()方法并添加您希望的任何逻辑。这种锚点不会重新加载页面。

Use tha Anchor element, and call its addClickListener() method and add in what ever logic you wish. This sort of anchor doesn't reload the page.

这篇关于GWT可点击的链接(锚点)没有href的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆