1. 程式人生 > >獲得windows對象如url,端口號等,定時顯示出來

獲得windows對象如url,端口號等,定時顯示出來

oca script 頁面 conf host type () idt 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,端口號等,定時顯示出來