zoukankan      html  css  js  c++  java
  • JS类小功能

    工作中,总是要处理一些前端的小功能。都是网上搜的JS脚本

    <script>
        //防止页面后退 
        history.pushState(null, null, document.URL);
        window.addEventListener('popstate', function () {
            history.pushState(null, null, document.URL);
        });
    </script>

    判断是否微信浏览器,相应显示与隐藏html元素

    <script type="text/javascript">
        function is_weixn(){
            var ua = navigator.userAgent.toLowerCase();
            if(ua.match(/MicroMessenger/i)!="micromessenger") {
                var box=document.getElementById("notify"); //div or span 
                var box2=document.getElementById("submit"); //<input id="submit" type="submit" value="提 交"> 
                box.style.display="inline";
                box2.style.display="none";
            } else {
                return false;
            }
        }
    </script>
    <body onload="is_weixn()">

    定时滚动的文本框:

    <script type="text/javascript">
    function startmarquee(lh,speed,delay,index){ 
        var t; 
        var p=false; 
        var o=document.getElementById("marqueebox"+index); 
        o.innerHTML+=o.innerHTML; 
        o.onmouseover=function(){p=true} 
        o.onmouseout=function(){p=false} 
        o.scrollTop = 0; 
        function start(){ 
            t=setInterval(scrolling,speed); 
            if(!p){ o.scrollTop += 1;} 
        } 
        function scrolling(){ 
            if(o.scrollTop%lh!=0){ 
                o.scrollTop += 1; 
                if(o.scrollTop>=o.scrollHeight/2) o.scrollTop = 0; 
            }else{ 
                clearInterval(t); 
                setTimeout(start,delay); 
            } 
        } 
        setTimeout(start,delay); 
    } 
    startmarquee(72,20,5000,0); 
    </script>
    <!-- html 部分-->
    <div class="box" id="marqueebox0"> 
    <div id="safetxt">...</div>
    <div id="safetxt2">...</div>
    </div>
  • 相关阅读:
    Mybatis动态SQL
    自己动手写一个持久层框架
    最长公共子串算法(Longest Common Substring)
    【SpringCloud】08.客户端负载均衡器:Ribbon
    ESP32 (idf-esp-v4.1)重新生成nvs分区
    IDEA导入新的springboot项目出错
    springboot集成mybatis出现问题/连接数据库出错
    Java学习周记2
    2020.8.6_Java学习日记
    9.23笔试总结
  • 原文地址:https://www.cnblogs.com/frx9527/p/webfront.html
Copyright © 2011-2022 走看看