Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross browser way of setting IFrame to "about:blank"?

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?

like image 687
Pekka Avatar asked Nov 06 '09 17:11

Pekka


People also ask

How do I create an empty iframe?

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.

Is about blank a valid URL?

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.

Is SRC required for iframe?

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).

Is iframe deprecated?

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.


1 Answers

How about

src="javascript: ;"

or

src="javascript:void(0)"

This should work fine with IE and Firefox

like image 50
marcgg Avatar answered Sep 30 '22 13:09

marcgg