« Iframe.contentDocument » ne fonctionne pas dans IE8 et FF (3,5 et ci-dessous) toute autre mesure pour résoudre ce problème?

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

Question

J'ai utilisé ce "iframe.contentDocument" dans js fichier Uploader, mais il ne fonctionne pas dans IE8, Firefox (3.5 et versions ci-dessous. Comment puis-je résoudre ce problème en utilisant d'autres de DOM pour travailler avec iframe?

Merci à tous

Était-ce utile?

La solution

Essayez

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);
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top