开发者

html question - button over anchor?

<button onclick="aprove(<?php echo $d["cod_team"]; ?>)">Aprove</button>
<开发者_如何学编程button onclick="refuse(<?php echo $d["cod_team"] ?>)">Refuse</button>

1) How can we give this same instructions to a A element?

2) Are there any cross-browser issues that I should be aware of?

K. Regards, MEM


<a href="#" onclick="...">Approve</a>

The # for the url guarantees that the browser won't leave this page, and otherwise the semantics would stay the same.


<a href="javascript:aprove(<?php echo $d["cod_team"]; ?>)">Approve</a>
<a href="javascript:refuse(<?php echo $d["cod_team"]; ?>)">Refuse</a>

Also:

<a href="#" onclick="aprove(<?php echo $d["cod_team"]; ?>)">;return false;">Approve</a>
<a href="#" onclick="refuse(<?php echo $d["cod_team"]; ?>)">;return false;">Refuse</a>

And, just for grins:

<a href="javascript:aprove(<?=$d["cod_team"]?>)">Approve</a>
<a href="javascript:refuse(<?=$d["cod_team"]?>)">Refuse</a>

And if you want a fallback:

<a href="approve.php?cod_team=<?=$d["cod_team"]?>" onclick="aprove(<?=$d["cod_team"]?>)">;return false;">Approve</a>
<a href="refuse.php?cod_team=<?=$d["cod_team"]?>" onclick="refuse(<?=$d["cod_team"]?>)">;return false;">Refuse</a>

Plus, there are other ways innumerate.

By the way, you misspelled approve in the function name.


same way:

<a href="javascript:void(0)" onclick="aprove(<?php echo $d["cod_team"]; ?>)">Aprove</a>

The javascript:void(0) part prevents the default behavior of the href thus preventing any page from loading.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜