AngularJs Get Browser Viewport Dimensions
home
Run
screen_rotation
fullscreen
cloud_download
<!DOCTYPE html> <html lang="en"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script> <script> var myApp = angular.module("myApp", []); myApp.controller("myController", function($scope) { $scope.height = ''; $scope.width = ''; $scope.getViewportDim = function() { $scope.height = Math.max(document.documentElement.clientWidth, window.innerWidth || 0) $scope.width = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) }; }); </script> </head> <body> <div ng-app="myApp"> <div ng-controller="myController"> <button ng-click='getViewportDim()' >Get Dim</button><br> Height = {{height}}PX<br> Width = {{width}}PX<br> </div> </div> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script> <script> var myApp = angular.module("myApp", []); myApp.controller("myController", function($scope) { $scope.height = ''; $scope.width = ''; $scope.getViewportDim = function() { $scope.height = Math.max(document.documentElement.clientWidth, window.innerWidth || 0) $scope.width = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) }; }); </script> </head> <body> <div ng-app="myApp"> <div ng-controller="myController"> <button ng-click='getViewportDim()' >Get Dim</button><br> Height = {{height}}PX<br> Width = {{width}}PX<br> </div> </div> </body> </html>
Copyrights@tutorialsplane.com