我试图找出我正在使用的模式对话框的宽度和高度:
我有以下 HTML:
<div data-ng-show="modal.visible" id="modal" style="height: 300px; width: 900px;">
<div class="block-border">
xxx
</div>
</div>
我有以下脚本:
$scope.openModal = function ($scope) {
var modal = document.getElementById('modal');
var modal_width = modal.offsetWidth
var modal_height = modal.offsetHeight;
var modal_width = parseInt(modal.width, 10)
var modal_height = parseInt(modal.height, 10)
var window_width = window.innerWidth;
var window_height = window.innerHeight;
modal.style.left = window_width / 2 - modal_width / 2;
modal.style.top = window_height / 2 - modal_height / 2;
$scope.modal.visible = true;
到目前为止,我获得模态高度和宽度的两种类型的检查似乎都没有工作,我不知道如何获得 modal_width 和 modal_height ?