0

Dieser Test (zum Senden eines Cross-Domain-AJAX oder nicht) ist immer falsch im Internet Explorer, aber es funktioniert auf Microsoft Edge.Fehlertest Gleiche Herkunft auf IE

Es sieht so aus, als ob das Element <a> in IE nicht aufgefüllt wird.

function testSameOrigin(url){ 
    /* 
     Return true if belongs to the same origin 
    */ 
    var loc = window.location, 
     a = document.createElement('a'); 

    a.href = url; 

    return a.hostname == loc.hostname && 
      a.port == loc.port && 
      a.protocol == loc.protocol; 
} 

Wie kann ich das beheben?

Danke für Ihre Hilfe.

+0

Existiert Internet Explorer 12? die höchste Version ist 11.0.28 –

+0

ja, die 12 und 13 ist es nicht IE aber die neue Microsoft Edge nur auf Windows 10. – Acute

+0

Edge ist komplett neu geschrieben, könnte es gleich Chrom oder Firefox sein lol: P –

Antwort

0

ich es beheben:

function testSameOrigin(url){ 

     var canonicalize = function(url) { 
      var div = document.createElement('div'); 
      div.innerHTML = "<a></a>"; 
      div.firstChild.href = url; 
      div.innerHTML = div.innerHTML; 
      return div.firstChild.href; 
     }; 

    var loc = window.location 
     , a = document.createElement('a'); 

    a.href = canonicalize(url); 

    return a.hostname == loc.hostname && 
      (a.port == loc.port || ((a.port == 80 || a.port == 443) && loc.port =="")) && 
      a.protocol == loc.protocol; 
} 

This post mir helfen, meinen Weg zu finden.