Python基础第27天
一:BOM对象(浏览器对象模型,可以对浏览器进行访问和操作)
Window 对象方法
alert()            显示带有一段消息和一个确认按钮的警告框。
confirm()          显示带有一段消息以及确认按钮和取消按钮的对话框。
prompt()           显示可提示用户输入的对话框。
open()             打开一个新的浏览器窗口或查找一个已命名的窗口。
close()            关闭浏览器窗口。
setInterval()      按照指定的周期(以毫秒计)来调用函数或计算表达式。
clearInterval()    取消由 setInterval() 设置的 timeout。
setTimeout()       在指定的毫秒数后调用函数或计算表达式。
clearTimeout()     取消由 setTimeout() 方法设置的 timeout。
scrollTo()         把内容滚动到指定的坐标。
setInterval clearInterval
<!--setInterval()      按照指定的周期(以毫秒计)来调用函数或计算表达式。-->
<!--clearInterval()    取消由 setInterval() 设置的 timeout。-->
<input type="text" id="id1" onclick="begin()" >
<button onclick="end()">停止</button>
<script>
    function showTime() {
        var current_time=new Date().toLocaleString();
        var ele=document.getElementById('id1');
        ele.value=current_time
    }
    var clock1;
    function begin() {
        if(clock1==undefined){
            showTime();
            clock1=setInterval(showTime,1000)
        }
    }
    function end() {
        clearInterval(clock1);
        clock1=undefined;
    }
</script>
setTimeout clearTimeout 在指定的毫秒数后调用函数或计算表达式
 
var ID = setTimeout(abc,2000); // 只调用一次对应函数. clearTimeout(ID); function abc(){ alert('aaa'); }
History 对象
back() 加载 history 列表中的前一个 URL。 forward() 加载 history 列表中的下一个 URL。 go() 加载 history 列表中的某个具体页面
<a href="rrr.html">click</a> <button onclick=" history.forward()">>>></button> <button onclick="history.back()">back</button> <button onclick="history.go()">back</button>
 
                    
                 
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号