2017-06-05 9 views
0

Chromeで完全に機能する次のコードがあります。Newをクリックすると、ポップアップが開き、Changeをクリックすると別のページにリダイレクトされます。IEでwindow.open()のリダイレクトが機能しない

JSBin

<!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でのリダイレクトのいくつかの方法を示していますthis threadを発見したIE 11では動作しません、私はそれらのどれも働いていないなど、location.href(...)location.assign(...)を試してみました。

IEでwindow.openのリダイレクトを達成する方法を知っている人はいますか?

答えて

1

documentationによると、window.location.href=は、IEのウィンドウのURLを設定(および取得)する最も良い方法のようです。

これが機能しない場合は、置き換えてください。$scope.popup.location.replace("https://www.google.com/");

+0

素晴らしい!それは動作します:https://plnkr.co/edit/dWT0kBNHSNgq134C6Sd4?p=preview – Thomas

+0

聞いて幸い;) – nitobuendia

関連する問題