我有一段代码可以在Chrome中完美运行。通过单击按钮,它会打开window.open
的弹出窗口,我们可以手动关闭弹出窗口,然后我们可以通过再次单击按钮重新打开弹出窗口:
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>
</head>
<body ng-controller="contentCtrl">
<button ng-click="openNew()">New</button>
<script>
var app = angular.module('plunker', []);
app.controller('contentCtrl', ['$scope', function ($scope) {
$scope.openNew = function () {
openPopup("https://www.stackoverflow.com")
}
function openPopup(url) {
console.log("openPopup");
console.log($scope.popup);
console.log(JSON.stringify($scope.popup))
if (($scope.popup === null) || ($scope.popup === undefined) || ($scope.popup.location === undefined) || ($scope.popup.location.href === undefined)) {
$scope.popup = window.open(url, "popup", "status=1, location=1, width=1000, height=1200, scrollbars=yes, resizable=yes");
} else {
$scope.popup.location.href = url;
}
}
}]);
</script>
</body>
</html>
但是,此代码在IE 11中不起作用:我们可以首次打开弹出窗口,然后在手动关闭弹出窗口后,单击按钮会导致无效。
有谁知道如何解决这个问题?