Does anybody know a proper, cross-browser way to "empty" an IFrame? Is "about:blank" recognized without error across all browsers? Is it valid to give an IFrame an empty src?
about:blank is the way to do it. Alternately, you could just insert the whole <iframe> element with JavaScript later, and don't worry about a valid "empty" src . Yea upon testing in Firefox, Chrome, Safari and IE 7/8/9 "about:blank" seems to be the best solution.
It is not an officially registered scheme, and has no standard syntax. There is no guarantee this will be accepted as a valid URL by all clients.
No, it is not valid to specify an empty iframe src. You should use <iframe src="about:blank" /> . # is meant to be a reference to an anchor within the current page (or, often used as a routing scheme when working with AJAX requests).
IFrames are not obsolete, but the reasons for using them are rare. Using IFrames to serve your own content creates a "wall" around accessing the content in that area. For crawlers like Google, It's not immediately clear that cotent in an iframe will be ranked as highly as if the content were simply part of the page.
How about
src="javascript: ;"
or
src="javascript:void(0)"
This should work fine with IE and Firefox
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With