Cross browser access html content of object tag
I have a tag object
with a data attribute in an html file from the same domain.
I want to access html content.
HTML:
<object id="object" width="420" height="360" data="jsp/index.html"></object>
JS:
var object = document.getElementById("object").contentDocument;
var html = object.getElementById("tmpl").innerHTML
The above code works in all browsers except IE7
Please help me in accessing the content of a DOM tag object
in IE7
source to share
Ok, so I tried to play around a bit with the code as provided and I learned some important things, first of all:
1> First I tried to get html content like this in firebug:
console.log(document.getElementById("iframe").contentDocument.innerHTML);
I'm going to bring my firebug result here:
So you can see there is a permission forbidden here.
2> I tried the same for the object as well and this is what I got:
From here it is pretty obvious that it fails because of the Same Origin Policy .
I don't know how you access them, but this domain and host is not available for me. This assumption is also the reason why you were unable to get the content of the object identifier. I suggest you use Cross Site HTTP Requests or the CORS way to do it here.
source to share