首页 > 代码库 > 小知识总结

小知识总结

1、自动跳转页面

<script  language="javascript" defer="defer">

        function doload()

        {

            window.close();

            opener.location.href = "http://www.mamicode.com/cgsgl.aspx";

        }

                   <%if(Request.Cookies["CGS_QQ_ID"]!=null) {%>

                            setTimeout("doload()",4000);

                  <%} %>

    </script>

2、自动省略

       1、文本自动省略

       <script type="text/javascript">

       function check(node){

              var str = node.firstChild.nodeValue;

              if(str.length>10){

                     node.firstChild.nodeValue = http://www.mamicode.com/str.substring(0,10) +"...";

              }

       }

       </script>

       2、屏蔽网页错误

       <script type="text/javascript">

       window.onerror=function(){return true;}

       </script>