• Javascrip 入门第三节课


     一、location对象

    location.href  获取当前网页的URL
    location.search() 获取?之后的请求信息 location.href="URL" // 跳转到指定页面 location.reload() 重新加载页面

    二、强弹出框

      alert('输入信息')

    alert("你看到了吗?");

    三、输入提示框

    prompt("提示语“) //弹出输入框

    四、计时器相关的函数 

    setTimeout('js语句',毫秒) #过多少毫秒后执行前面的语句;
    clearTimeout(setTimeout_variable) //参数为延时的变量名,取消延时设置
    ID=setInterval("JS语句",时间间隔) ;//设置每隔多少时间执行一次js语句;
    clearInterval(ID); //取消延时执行的程序
    function foo()
        {
        for (let i=0;i<10;i++)
        {
        console.log(i);
        }
        }
    setTimeout(foo,1000)

      定时器实例

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>计时器</title>
        <script type="text/javascript">
            function timer(){
                var date=new Date();
                console.log(date);
                ret=document.getElementById('delay')
                ret.value=date;
    
            }
    
            var ID;
            function start_timer(){
            /*判断定时器是否已经启动,如果启动,重复按无效*/
                if (ID==undefined)            
                {
                    timer();
                    ID=setInterval(timer,1000);
                }            
            }
            function end_timer(){
                clearInterval(ID);
                //计时停止后,我们需要将ID的值还原为undefined,否则点击start无效
                ID=undefined;
            }
        </script>
    </head>
    <body>
        <input type="text" name="delaytime" id='delay' class="c1">
        <button onclick='start_timer()'>start</button><button onclick="end_timer()">end</button>
        
    </body>
    </html>
    定时器代码示例

  • 相关阅读:
    struct和typedef struct彻底明白了
    jsoncpp使用
    JsonCpp使用注意
    vscode 远程 Linux 开发环境搭建
    Ubuntu 更换国内源
    java~PECS原则
    DLL劫持——DLL sideloading 这玩意从EDR检测厂商看,就S1有防护能力
    apache jmeter报告模板
    http压测工具 jmeter 安装配置
    golang项目部署
  • 原文地址:https://www.cnblogs.com/angle6-liu/p/10168944.html
Copyright © 2020-2023  润新知