How to get innerHTML of an iframe with the latest browser versions like IE11, Chrome 71, Firefox 62(Quantum)
I am using IE11, Chrome 71 and Firefox 62(Quantum) browsers. I am just experimenting with iframe to upload the file(it's not a cross domain). The same code was working fine with IE7 earlier.We are making our project a browser agnostic now. I just want to know what is the best way to get innerHTML of the iframe with latest browsers. I have tried with the following approaches, but nothing worked for me.
1)
iframeId = document.getElementById("upload_iframe");
content = iframeId.contentDocument.body.innerHTML;
2) $('#iframeId ').contents().find('body').innerHTML
3) $('#iframeId ').contents().find('body').html();
4)
iframeId = document.getElementById("upload_iframe");
iframeId.contentWindow.document.body.innerHTML
5)
iframeId = document.getElementById("upload_iframe");
iframeId.document.body.innerHTML
Any help is much apprecited.
javascript jquery html iframe
add a comment |
I am using IE11, Chrome 71 and Firefox 62(Quantum) browsers. I am just experimenting with iframe to upload the file(it's not a cross domain). The same code was working fine with IE7 earlier.We are making our project a browser agnostic now. I just want to know what is the best way to get innerHTML of the iframe with latest browsers. I have tried with the following approaches, but nothing worked for me.
1)
iframeId = document.getElementById("upload_iframe");
content = iframeId.contentDocument.body.innerHTML;
2) $('#iframeId ').contents().find('body').innerHTML
3) $('#iframeId ').contents().find('body').html();
4)
iframeId = document.getElementById("upload_iframe");
iframeId.contentWindow.document.body.innerHTML
5)
iframeId = document.getElementById("upload_iframe");
iframeId.document.body.innerHTML
Any help is much apprecited.
javascript jquery html iframe
add a comment |
I am using IE11, Chrome 71 and Firefox 62(Quantum) browsers. I am just experimenting with iframe to upload the file(it's not a cross domain). The same code was working fine with IE7 earlier.We are making our project a browser agnostic now. I just want to know what is the best way to get innerHTML of the iframe with latest browsers. I have tried with the following approaches, but nothing worked for me.
1)
iframeId = document.getElementById("upload_iframe");
content = iframeId.contentDocument.body.innerHTML;
2) $('#iframeId ').contents().find('body').innerHTML
3) $('#iframeId ').contents().find('body').html();
4)
iframeId = document.getElementById("upload_iframe");
iframeId.contentWindow.document.body.innerHTML
5)
iframeId = document.getElementById("upload_iframe");
iframeId.document.body.innerHTML
Any help is much apprecited.
javascript jquery html iframe
I am using IE11, Chrome 71 and Firefox 62(Quantum) browsers. I am just experimenting with iframe to upload the file(it's not a cross domain). The same code was working fine with IE7 earlier.We are making our project a browser agnostic now. I just want to know what is the best way to get innerHTML of the iframe with latest browsers. I have tried with the following approaches, but nothing worked for me.
1)
iframeId = document.getElementById("upload_iframe");
content = iframeId.contentDocument.body.innerHTML;
2) $('#iframeId ').contents().find('body').innerHTML
3) $('#iframeId ').contents().find('body').html();
4)
iframeId = document.getElementById("upload_iframe");
iframeId.contentWindow.document.body.innerHTML
5)
iframeId = document.getElementById("upload_iframe");
iframeId.document.body.innerHTML
Any help is much apprecited.
javascript jquery html iframe
javascript jquery html iframe
edited Nov 21 '18 at 7:10
Ashok.N
asked Nov 21 '18 at 7:04
Ashok.NAshok.N
56531238
56531238
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
did you try the following?
window.frames['upload_iframe'].document.body.innerHTML
(for IE)
window.frames[0].document.body.innerHTML
(for Firefox and Chrome)
,Thanks for the response. But your suggestion is not working for me. I am gettingUncaught TypeError: Cannot read property 'innerHTML' of null
becausewindow.frames[0].document.body
itself is becoming null . Any other thoughts please..
– Ashok.N
Nov 21 '18 at 8:14
try changing the 0 to your frame idwindow.frames['upload_iframe'].document.body.innerHTML
– Mustafa Anas
Nov 21 '18 at 8:20
still the same error after changing it towindow.frames['upload_iframe'].document.body.innerHTML
– Ashok.N
Nov 21 '18 at 8:23
if not, my last suggestion would be to try using contentDocument property [w3schools.com/jsref/prop_frame_contentdocument.asp]
– Mustafa Anas
Nov 21 '18 at 8:25
Still not working.iframeId.body
is coming asundefined
, not sure what to do after this.
– Ashok.N
Nov 21 '18 at 9:02
|
show 1 more comment
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53406832%2fhow-to-get-innerhtml-of-an-iframe-with-the-latest-browser-versions-like-ie11-ch%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
did you try the following?
window.frames['upload_iframe'].document.body.innerHTML
(for IE)
window.frames[0].document.body.innerHTML
(for Firefox and Chrome)
,Thanks for the response. But your suggestion is not working for me. I am gettingUncaught TypeError: Cannot read property 'innerHTML' of null
becausewindow.frames[0].document.body
itself is becoming null . Any other thoughts please..
– Ashok.N
Nov 21 '18 at 8:14
try changing the 0 to your frame idwindow.frames['upload_iframe'].document.body.innerHTML
– Mustafa Anas
Nov 21 '18 at 8:20
still the same error after changing it towindow.frames['upload_iframe'].document.body.innerHTML
– Ashok.N
Nov 21 '18 at 8:23
if not, my last suggestion would be to try using contentDocument property [w3schools.com/jsref/prop_frame_contentdocument.asp]
– Mustafa Anas
Nov 21 '18 at 8:25
Still not working.iframeId.body
is coming asundefined
, not sure what to do after this.
– Ashok.N
Nov 21 '18 at 9:02
|
show 1 more comment
did you try the following?
window.frames['upload_iframe'].document.body.innerHTML
(for IE)
window.frames[0].document.body.innerHTML
(for Firefox and Chrome)
,Thanks for the response. But your suggestion is not working for me. I am gettingUncaught TypeError: Cannot read property 'innerHTML' of null
becausewindow.frames[0].document.body
itself is becoming null . Any other thoughts please..
– Ashok.N
Nov 21 '18 at 8:14
try changing the 0 to your frame idwindow.frames['upload_iframe'].document.body.innerHTML
– Mustafa Anas
Nov 21 '18 at 8:20
still the same error after changing it towindow.frames['upload_iframe'].document.body.innerHTML
– Ashok.N
Nov 21 '18 at 8:23
if not, my last suggestion would be to try using contentDocument property [w3schools.com/jsref/prop_frame_contentdocument.asp]
– Mustafa Anas
Nov 21 '18 at 8:25
Still not working.iframeId.body
is coming asundefined
, not sure what to do after this.
– Ashok.N
Nov 21 '18 at 9:02
|
show 1 more comment
did you try the following?
window.frames['upload_iframe'].document.body.innerHTML
(for IE)
window.frames[0].document.body.innerHTML
(for Firefox and Chrome)
did you try the following?
window.frames['upload_iframe'].document.body.innerHTML
(for IE)
window.frames[0].document.body.innerHTML
(for Firefox and Chrome)
answered Nov 21 '18 at 7:33
Mustafa AnasMustafa Anas
148
148
,Thanks for the response. But your suggestion is not working for me. I am gettingUncaught TypeError: Cannot read property 'innerHTML' of null
becausewindow.frames[0].document.body
itself is becoming null . Any other thoughts please..
– Ashok.N
Nov 21 '18 at 8:14
try changing the 0 to your frame idwindow.frames['upload_iframe'].document.body.innerHTML
– Mustafa Anas
Nov 21 '18 at 8:20
still the same error after changing it towindow.frames['upload_iframe'].document.body.innerHTML
– Ashok.N
Nov 21 '18 at 8:23
if not, my last suggestion would be to try using contentDocument property [w3schools.com/jsref/prop_frame_contentdocument.asp]
– Mustafa Anas
Nov 21 '18 at 8:25
Still not working.iframeId.body
is coming asundefined
, not sure what to do after this.
– Ashok.N
Nov 21 '18 at 9:02
|
show 1 more comment
,Thanks for the response. But your suggestion is not working for me. I am gettingUncaught TypeError: Cannot read property 'innerHTML' of null
becausewindow.frames[0].document.body
itself is becoming null . Any other thoughts please..
– Ashok.N
Nov 21 '18 at 8:14
try changing the 0 to your frame idwindow.frames['upload_iframe'].document.body.innerHTML
– Mustafa Anas
Nov 21 '18 at 8:20
still the same error after changing it towindow.frames['upload_iframe'].document.body.innerHTML
– Ashok.N
Nov 21 '18 at 8:23
if not, my last suggestion would be to try using contentDocument property [w3schools.com/jsref/prop_frame_contentdocument.asp]
– Mustafa Anas
Nov 21 '18 at 8:25
Still not working.iframeId.body
is coming asundefined
, not sure what to do after this.
– Ashok.N
Nov 21 '18 at 9:02
,Thanks for the response. But your suggestion is not working for me. I am getting
Uncaught TypeError: Cannot read property 'innerHTML' of null
because window.frames[0].document.body
itself is becoming null . Any other thoughts please..– Ashok.N
Nov 21 '18 at 8:14
,Thanks for the response. But your suggestion is not working for me. I am getting
Uncaught TypeError: Cannot read property 'innerHTML' of null
because window.frames[0].document.body
itself is becoming null . Any other thoughts please..– Ashok.N
Nov 21 '18 at 8:14
try changing the 0 to your frame id
window.frames['upload_iframe'].document.body.innerHTML
– Mustafa Anas
Nov 21 '18 at 8:20
try changing the 0 to your frame id
window.frames['upload_iframe'].document.body.innerHTML
– Mustafa Anas
Nov 21 '18 at 8:20
still the same error after changing it to
window.frames['upload_iframe'].document.body.innerHTML
– Ashok.N
Nov 21 '18 at 8:23
still the same error after changing it to
window.frames['upload_iframe'].document.body.innerHTML
– Ashok.N
Nov 21 '18 at 8:23
if not, my last suggestion would be to try using contentDocument property [w3schools.com/jsref/prop_frame_contentdocument.asp]
– Mustafa Anas
Nov 21 '18 at 8:25
if not, my last suggestion would be to try using contentDocument property [w3schools.com/jsref/prop_frame_contentdocument.asp]
– Mustafa Anas
Nov 21 '18 at 8:25
Still not working.
iframeId.body
is coming as undefined
, not sure what to do after this.– Ashok.N
Nov 21 '18 at 9:02
Still not working.
iframeId.body
is coming as undefined
, not sure what to do after this.– Ashok.N
Nov 21 '18 at 9:02
|
show 1 more comment
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53406832%2fhow-to-get-innerhtml-of-an-iframe-with-the-latest-browser-versions-like-ie11-ch%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown