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

后端 未结 3 1460
醉酒成梦
醉酒成梦 2021-02-19 13:43

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 is

相关标签:
3条回答
  • 2021-02-19 14:30

    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.

    0 讨论(0)
  • 2021-02-19 14:43

    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

    0 讨论(0)
  • 2021-02-19 14:46

    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.

    0 讨论(0)
提交回复
热议问题