First <a tag> onclick
--> doesn't work (a tag onclick
) but second button onclick
--> works.
Anyone knows what's the problem with <a>
tag??
function content(frm) {
var url = "noticeContent.jsp";
var title = "test";
var status = "toolbar=no,directories=no,scrollbars=no,resizable=no,status=no,menubar=no,width=240, height=200, top=0,left=20"
window.open("", title,status);
frm.target = title;
frm.action = url;
frm.method = "post";
frm.submit();
}
<form name="f_name">
<input type="hidden" name="a" value="1">
<input type="hidden" name="b" value="2">
<td><a href="javascript:" onclick="content(this.form)"></a></td>
<td><input type="button" onclick="javascript:content(this.form)"></td>
</form>
答案 0 :(得分:0)
将返回false添加到<a>
代码,以避免<a>
的默认行为
<td><a href="javascript:" onclick="content(this.form);return false;"></a></td>
但是我会建议你将javascript和HTML分开以便于阅读,而不是在这种情况下使用锚标记。