【发布时间】:2017-11-06 07:36:09
【问题描述】:
我有以下在 Chrome 中完美运行的代码:通过单击 New,它会打开一个弹出窗口,然后单击 Change 会重定向到另一个页面。
<!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的重定向?
【问题讨论】:
标签: javascript internet-explorer cross-browser window.open