Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
177
rated 0 times [  180] [ 3]  / answers: 1 / hits: 34230  / 14 Years ago, fri, november 26, 2010, 12:00:00

I would like to create an <iframe> on the page, but then add the src later. If I make an iframe without an src attribute, then it loads the current page in some browsers. What is the correct value to set for the src so that it just loads a blank iframe?



The answers I've seen are:




  • about:blank

  • javascript:false

  • javascript:void(0)

  • javascript:;

  • url to a blank page



Is there a clear winner? If not, what are the tradeoffs?



I'd like to not have mixed content warnings for HTTPS urls, nor any back-button, history, or reload weirdness in all browsers from IE6 onward.


More From » html

 Answers
6

Standard approach when creating an empty iframe (as an iframe shim, for example), is to set the src as javascript:false;. This is the method used by most of the JavaScript libraries that create iframe shims for you (e.g. YUI's Overlay).


[#94837] Tuesday, November 23, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kadinl

Total Points: 321
Total Questions: 117
Total Answers: 103

Location: Nepal
Member since Mon, Jan 4, 2021
3 Years ago
;