This doesn’t work:
if(document.getElementById("iframe").innerHTML==''){
Is there a safe browser reliable way to check an iframe if its empty or not?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well if you can use jQuery, check it’s
lengthproperty. This is cross-browser compatible. If it’s zero, it doesn’t exist. Something like this:EDIT:
After seeing your comments on your question:
If you want to check if no page loaded inside iframe, and the iframe is not cross-domain you could check for the existence of the
bodytag inside of the iframe. If it exists, then something loaded.Something like this:
If the iframe is cross-domain, you will be blocked by the same-origin policy. Otherwise this will work.