myeclipse Web项目,jsp里点击按钮后,操作成功或失败了怎样给出提示并实现页面跳转?提示要自动消失的

如题所述

1. 在要提示的地方定义一个span,可以设置提示条件,加个ID,里面的内容暂时为空;
2. 出错的时候,获取提示span,把span的innerHTML设置成错误字符串;
3. 同时设置一个定时器,定时时间为提示显示时长,回调函数中将span的innerHTML设为空字符串;
4. 页面跳转也可以加在回调函数上。追问

能不能麻烦你给点儿代码提示呀?

追答

输入框后面加个
在你的判断函数中 加上如下代码
如果成功 document.getElementById("errorInfo").innerHTML="成功";
反之 document.getElementById("errorInfo").innerHTML="失败";
然后定义一个定时器及回调函数
setTimeout(removeErrorInfo(),3000) //单位毫秒
function removeErrorInfo() { document.getElementById("errorInfo").innerHTML="";

//这里面再处理跳转 如location.href =目标地址,或者再加个定时器在回调函数里面跳转

}

温馨提示:内容为网友见解,仅供参考
第1个回答  2013-05-02
这个直接使用alert("操作成功"),弹出对话框就好了。或者你也可以用dialog
$(function() {
$( "#dialog" ).dialog({
autoOpen: false,
modal: true,
width: 200
});
});

<div id="dialog">
<div class="dialogDiv">
<div class="info">
<p id="content"></p>
</div>
</div>
</div>
页面跳转用location.href="a.jsp";
提示自动消失要写一个方法
function test(){
$("#dialog").dialog("close");
}
setTimeout("test()",3000);
这个是设置3秒自动消失
第2个回答  2013-05-02
用纯html就可以实现了追问

纯html提示了怎么消失啊

追答

不用alert 用div 设置一个div display=block 然后3秒钟后display=none 并且执行跳转

相似回答