How to clear the content of an IFRAME?

前端 未结 10 2456
感情败类
感情败类 2020-12-14 05:17

How do I clear the content of my IFRAME element, using javascript, without loading a blank page into it?

I can figure out to do this: iframe_element.src = \"bl

10条回答
  •  臣服心动
    2020-12-14 06:13

    Your technique is the most robust. Its the one I use myself. At times content may be delivered over HTTPS and the use of about:blank can cause warning messages to appear to the effect of "do you want to include content from unsecure location" or some such thing.

    Something being instant is a matter of perception however if you have a single Blank.html file on your site configured with a long cache expiry the client will only ever fetch the page once (at the most once per-session).

提交回复
热议问题