獲得windows對象如url,連接埠號碼等,定時顯示出來

來源:互聯網
上載者:User

標籤:har   部分   var   fun   on()   angular   nbsp   width   col   

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <script type="text/javascript" src="angular.js" ></script>
        <script>
            var app = angular.module("myapp",[]);
            app.controller("myctrl",function($scope,$timeout){
                //擷取寬度
                var wd = window.screen.width;
                $timeout(function(){
                    $scope.widths = wd;
                },2000);
                
                //擷取高度
                var hg = window.screen.height;
                $timeout(function(){
                    $scope.heights = hg;
                },2000);
                
                //擷取title
                var tt = document.getElementById("biaoti").innerHTML;
                $timeout(function(){
                    $scope.titles = tt;
                },3000);
                
                //擷取url協議
                var ur = window.location.protocol;
                $timeout(function(){
                    $scope.urls = ur;
                },3000);
                
                //擷取url主機
                var hs = window.location.host;
                $timeout(function(){
                    $scope.urlss = hs;
                },3000);
                
                //擷取連接埠號碼
                var po = window.location.port;
                 $timeout(function(){
                    //$scope.dkhs = po;
                    var cf = confirm("是否顯示連接埠號碼");
                    if(cf==true){
                        $scope.dkhs = po;
                    }
                },5000);
                
                //擷取URL的hash部分
                var ha = window.location.pathname.hash;
                $timeout(function(){
                    //$scope.dkhs = po;
                    var cf = confirm("是否顯示URL的hash部分");
                    if(cf==true){
                        $scope.hashs = ha;
                    }
                },5000);
                
                //擷取訪問地址
                var pn = window.location.pathname;
                $timeout(function(){
                    //$scope.dkhs = po;
                    var cf = confirm("是否顯示訪問地址");
                    if(cf==true){
                        $scope.dzs = pn;
                    }
                },5000);

            });
            
        </script>
        <title id="biaoti">123</title>
    </head>
    <body ng-app="myapp" ng-controller="myctrl">
        <p>頻幕寬度是:{{widths}}</p>
        <p>頻幕高度度是:{{heights}}</p>
        <p>頁面title是:{{titles}}</p>
        <p>URL協議是:{{urls}}</p>
        <p>URL主機是:{{urlss}}</p>
        <p>連接埠號碼是:{{dkhs}}</p>
        <p>URL的hash部分是:{{hashs}}</p>
        <p>訪問地址是:{{dzs}}</p>
    </body>
</html>

獲得windows對象如url,連接埠號碼等,定時顯示出來

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.