What is the difference between “javascript:”, “#”, and “javascript:false” in iframe.src attribute

穿精又带淫゛_ 提交于 2019-12-07 21:37:08

问题


If I want to set the src of iframe with these 3 value. I found:

  1. javascript: doesn't work in IE10 (error is can't find the page). other mainstream browsers or IE9 is ok.
  2. javascript:false will show a false string in the iframe for IE10, others browsers or IE9 is ok.
  3. # works fine in all the browsers.

What is the difference between them? Which one is the best choice for cross-browser issues?


回答1:


Try using about:blank as the URL. This should display a blank page in all browsers.

http://tools.ietf.org/html/rfc6694#section-3




回答2:


If you want an iframe that doesn't load anything right away, then just don't set the src attribute to anything. You can set the .src property later via Javascript to cause it to load something.



来源:https://stackoverflow.com/questions/20535222/what-is-the-difference-between-javascript-and-javascriptfalse-in-ifr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!