0
我有以下代码在Chrome中完美工作:点击New
,它打开一个弹出窗口,然后点击Change
导致重定向到另一个页面。window.open()的重定向在IE中不起作用
<!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>
<button ng-click="change()">Change</button>
<script>
var app = angular.module('plunker', []);
app.controller('contentCtrl', ['$scope', function ($scope) {
$scope.openNew = function() {
$scope.popup = window.open("https://www.stackoverflow.com", "popup", "status=1, location=1");
}
$scope.change = function() {
// $scope.popup = window.open("https://www.sina.com", "popup", "status=1, location=1");
// $scope.popup.location.assign("https://www.sina.com")
// $scope.popup.location.href("https://www.sina.com")
// $scope.popup.location = "https://www.sina.com"
$scope.popup.location.href = "https://www.sina.com"
}
}]);
</script>
</body>
</html>
然而,这个代码不工作在IE 11,我发现this thread列出重定向的几种方法在IE中,我试图location.assign(...)
,location.href(...)
等没有一次成功。
有谁知道如何在IE中实现window.open的重定向?
太棒了!它的工作原理:https://plnkr.co/edit/dWT0kBNHSNgq134C6Sd4?p=preview – Thomas
很高兴听到;) – nitobuendia