BOM编程

window窗口操作

<<!DOCTYPE html>
<html>
<head>
    <title>构造器</title>
</head>
<body>
    <script type="text/javascript">
    var win=window.open('http://www.baidu.com','wroxWindow','height=400,width=400,top=10,left=10,resizeable=yes');
    win.resizeTo(500,500);
    win.moveTo(100,100);
    win.close();
    </script>
</body>
</html>

延时操作和间歇操作

JavaScript是单线程语言

//  延时执行
    var delayTask = setTimeout(function(){
        alert("I delay 2 seconde!");
    },2000);

    clearTimeout(delayTask);
// 间歇执行

    setInterval(function(){
        console.log('hehe');
    },1000);

对话框

  • confirm(msg)
  • alert(msg)
  • print()打印
    if(confirm('are you ok?')) {
        alert('i am ok');
    }else{
        print();//显示打印窗口
    }

location对象

replace
reload
assign
href

跳转到地址栏:
``` stylus
//调用方法设置地址
location.assign('http://www.baidu.com');
//修改属性设置地址
location.href='http://www.baidu.com';

setTimeout(function(){
location.replace('http://www.sina.com');
},2000);

setTimeout(function(){
location.reload(true);//重新从服务器加载
},5000);




<div class="se-preview-section-delimiter"></div>

检测插件

// navigator
(function (){
    for (var i = 0; i < navigator.plugins.length; i++) {
        console.log(navigator.plugins[i].name);
     }
 })();

Widevine Content Decryption Module
Shockwave Flash
Chrome PDF Viewer
Native Client
Chrome PDF Viewer


screen对象

与窗口对象不同,screen获取的是浏览器外显示器(屏幕)的信息

    alert(screen.height+'height\n'+screen.width+'width');




<div class="se-preview-section-delimiter"></div>

768 height
1366 width

还有很多其他属性,可以查看文档


history对象

很明显与窗口页面有关,可以控制页面跳转

    history.back();
    history.forward();
    history.go(2);//前进两页
    history.go(-1);//后退一页
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值