“Iframe.contentDocument” che non funziona in IE8 e FF (3.5 e sotto) eventuali altre misure per risolvere questo problema?

StackOverflow https://stackoverflow.com/questions/4310946

Domanda

Ho usato questo "iframe.contentDocument" in js di file-uploader, Ma non funziona in IE8, Firefox (3.5 e versioni di seguito. Come posso risolvere questo utilizzando altri DOM di per lavorare con iframe?

Grazie a tutti

È stato utile?

Soluzione

Prova

var doc;
var iframeObject = document.getElementById('iframeID'); // MUST have an ID
if (iframeObject.contentDocument) { // DOM
  doc = iframeObject.contentDocument;
} 
else if (iframeObject.contentWindow) { // IE win
  doc = iframeObject.contentWindow.document;
}
if (doc) {
  var something = doc.getElementById('someId');
}
else {
  alert('Wonder what browser this is...'+navigator.userAgent);
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top