1.页面的前进后退:
<input type=button value=刷新 onclick="window.location.reload()">
<input type=button value=前进 onclick="window.history.go(1)">
<input type=button value=后退 onclick="window.history.go(-1)">
<input type=button value=前进 onclick="window.history.forward()">
<input type=button value=后退 onclick="window.history.back()">
如果是图片链接<a href="javascript:history.go(-1)">pic</a>
3.页面上面控件规定时间内显示:
<SCRIPT language=javascript type=text/javascript>
function disappear(){
var nowDate = new Date();
var month = nowDate.getMonth()+1;
var nowHour = nowDate.getHours();
var date = nowDate.getDate();
if(month == 7 && 17<=date && date <=21){
var divElement = document.getElementById("divbox");
if(date == 21 && nowHour >12){
divElement.style.display="none";
}else{
divElement.style.display="block";
}
}
}
4.锚点的设置 <a href="#huifutiezi"> 相当于设置锚点,点击直接跳转到下面这个a的位置 下面设置<a> <a name="huifutiezi" id="huifutiezi"></a>
3.jquey的使用,异步提交 function doSubmit(){ var content = document.fasong.cl_cont2.value; var code = document.fasong.yzm.value; var artId = document.fasong.fa_Id.value; var numTest = /^/d{4}$/; var parten = /^/s*$/; if((content=="")||(parten.test(content))||
trim(content) == ""){ alert("回复内容不能为空"); return false; } if(content.length>1000){ alert("您输入的内容太长,多余的内容将不会提交!"); return false; } if(code.length == 0){ alert("嗨!您还没有输入验证码呢,无法回复帖子!"); return false; }else if(!numTest.test(code)){ alert("对不起,您输入的图形验证码有误,请重新输入!"); document.fasong.yzm.value = ""; return false; }else{ $.ajax({ url: "/fetion/addFetionReArt.action", data:
$('#fasong').formSerialize(), type:
'POST', success:
function(data){ if(!data){ location.href="/front/register/login.jsp"; }else{ var
dd =
data.substring(0,4); if(dd=="回复成功"){ alert(dd);
var dqy = data.substring(4); document.fasong.cl_cont2.value = ""; location.href="/fetion/goFetionArt.action?fa_Id="+artId+"&flag=1&dqy="+dqy; //location.href 是直接调用这个链接,可用页面跳转用; } else{ alert(data); show(document.getElementById('random')); document.fasong.yzm.value = ""; } } } }); } } 这个data是从action通过toclient方法返回回来的 /** * 返回客户端信息 *
@param msg *
@return */ private void toClient(String msg) { HttpServletResponse
response = ServletActionContext.getResponse(); response.setCharacterEncoding("UTF-8"); try
{ PrintWriter out = response.getWriter(); out.write(msg); out.flush(); out.close(); }
catch (IOException e) { e.printStackTrace(); } }