警报框在jsp中不起作用
alert box not working in jsp
我在页面中添加了一个时尚的提醒框,资源就在这里。但问题是单击ok
后,confirmsubmit.jsp
不会打开。同样在该警报中cancel
按钮没有出现的原因是什么?
javascript
<form action="confirmsubmit.jsp" method="POST">
<script type="text/javascript">
<!--
function confirmation() {
var answer = csscody.alert("Confirm submit?")// added csscody here for alert but after clicking ok nothing happens
if (answer){
window.location = "confirmsubmit.jsp";
}
else{
return false;// here cancel button is not coming
}
}
//-->
</script>
</form>
html
<input type="text" name="textboxname"/>
<input type="submit" onclick="return confirmation()"/>
</form>
更新
查看下面的代码,它使用按钮而不是链接
<form action="confirmsubmit.jsp" method="POST">
<script type="text/javascript">
$().ready(function() {
$('#btn_submit').click(function(e) {
e.preventDefault();
var that = this;
var text = "si o no compa?";
csscody.confirm(text, {
onComplete: function(e) {
if (e) {
window.location = "confirmsubmit.jsp";
}
else {
return false;
}
}
})
});
});
</script>
<input type="text" name="textboxname"/>
<input type="submit" id="btn_submit" onclick="return confirmation()"/>
</form>
您将不得不使用confirm
而不是alert
,这将分别返回true
和false
的确定和取消按钮。并从onclick
上取下return
HTML
<form action = "confirmsubmit.jsp" method = "POST">
<input type = "text" name = "textboxname" />
<input type = "submit" onclick = "confirmation();" />
</form>
Javascript
function confirmation() {
var answer = confirm("Confirm submit?");
if (answer){
window.location = "confirmsubmit.jsp";
}
else{
return false;
}
}
相关文章:
- Javascript函数在jsp文件中不起作用
- 使用jQuery在jsp中分页不起作用
- 来自JSP的字符串在JavaScript上不起作用
- JSP if() 语句中的 HTML 不起作用
- JSP-Javascript-JSP 登录流程不起作用
- 简单的脚本在 jsp 页面中不起作用
- 使用 href=“#” JQuery 工作,但使用 href=“page.jsp” 不起作用
- jsp Ajax 不起作用
- 当表单操作使用Apache Shiro转到jsp页面时,onClick不起作用
- 函数在 JSP 页面中不起作用
- JQuery 在带有 Struts2 的 JSP 中不起作用
- window.open()在JSP中传递变量时不起作用
- 警报框在jsp中不起作用
- 为什么我的javascript在jsp页面中不起作用
- 为什么我的jsp代码中的搜索按钮不起作用
- JSP:Insert不起作用(SQLSERVER)
- JSP将带有XML字符的String属性传递给JavaScript函数不起作用
- sortable.js在JSP页面中不起作用
- ajax和JSP的表单验证不起作用
- 设置jsp上的Ajax响应不起作用