js 锚点,时间

1.页面的前进后退

  <input   type=button   value=刷新   οnclick="window.location.reload()"> 

  <input   type=button   value=前进   οnclick="window.history.go(1)"> 

  <input   type=button   value=后退   οnclick="window.history.go(-1)"> 

  <input   type=button   value=前进   οnclick="window.history.forward()"> 

  <input   type=button   value=后退   οnclick="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();

              }

       }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值