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?
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.
Use the embed Tag as an Alternative to Iframe in HTML The embed tag is similar to the object tag, and it is used for the same purpose. We can embed various external resources in our web page using the embed tag. We can embed media like PDF, image, audio, video, and web pages.
The src attribute specifies the address of the document to embed in an iframe.
No, there isn't an equivalent. The <iframe> element is still valid in HTML5. Depending on what exact interaction you need there might be different APIs. For example there's the postMessage method which allows you to achieve cross domain javascript interaction.
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
.
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.
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