1. 程式人生 > >JS-property-5秒後跳轉到百度

JS-property-5秒後跳轉到百度

<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <title>Document</title>
 </head>
 <body>
  <script>
        function testScreen(){
            var w = screen.width;
            var h = screen.height;
            alert("寬度:"+w+",高度:"+h);
            var aw = screen.availWidth;
            var ah = screen.availHeight;
            alert("可用寬度:"+aw+",可用高度:"+ah);
        }

        function testLocation(){
            alert("5秒鐘之後,跳轉到百度");
            setTimeout(function(){
                location.href="http://www.baidu.com";
            },5000);
        }
            
    </script>
    <button onclick="testScreen()">測試Screen</button>
    <button onclick="testLocation()">測試Location</button>
 </body>
</html>