javascript - how to hide an iframe if content is empty -
i using iframe in displaying content external url. want hide iframe if there no content display (i.e empty). please let me know how this.
if want check content external url inside iframe empty, , iframe not cross-domain check existence of body tag inside of iframe. if exists, loaded. if can use jquery, check it's length
property. cross-browser compatible. if it's zero, doesn't exist.
code:
if($("#iframeid").contents().find("body").length) { // html page loaded in iframe }
if iframe cross-domain, blocked same-origin policy. otherwise work.
Comments
Post a Comment