Create an iframe with an empty src that's a standards compliant alternative to "#"

Go To StackoverFlow.com

10

I have an iframe on a page that I need to initially have a blank src for, as I eventually set the src with javascript.

I had been using a however have encountered an issue in Safari and Chrome where this loads a duplicate copy of my page within the iframe.

I read about "about:blank" in another question, however I've read that IE9 sends a null request to the server when you use this as the src. I've also yet to find anything listing this src as standards compliant.

Does anyone have an alternative to "about:blank" that they use to create an empty iframe?

2012-04-04 18:23
by A.Wack


12

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.

2012-04-04 18:28
by Matt Ball
Yea upon testing in Firefox, Chrome, Safari and IE 7/8/9 "about:blank" seems to be the best solution. I have yet to verify wether or not IE9 actually pings the server when using that src, but even if it does that's about the same as pointing the src to a dummy page on the site - A.Wack 2012-04-04 19:05


3

One of the linkers in Google Web Toolkit contains a dynamically created iframe. They use javascript:'' as a temporary placeholder for the src attribute. The reason, according to the source comments, is "Prevents mixed mode security in IE6/7.".

Source.

2012-10-03 08:14
by Henrik Aasted Sørensen


0

As part of the about URI scheme standard, about:blank is probably the best option as it has very good browser support.

about:blank Returns a blank HTML document with the media type text/html and character encoding UTF-8. This is widely used to load blank pages into browsing contexts, such as iframes within HTML, which may then be modified by scripts. You can see further here

2015-01-06 01:12
by Selay
Ads