9

I used this "iframe.contentDocument" in js file-uploader , But it not working in IE8 ,Firefox(3.5 and below versions. How can i solve this by using other DOM's for working with iframe ?

Thanks to all

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
ajay
  • 119
  • 1
  • 7
  • I believe there are differences between how IE, FF, etc., handles iframe.contentDocument. You could try a jQuery approach. Check out http://www.dynamicdrive.com/forums/showthread.php?t=29359 – matthewpavkov Nov 30 '10 at 06:12

1 Answers1

11

Try

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);
}
mplungjan
  • 169,008
  • 28
  • 173
  • 236