Detect if the iframe content has loaded successfully

前端 未结 6 951
天命终不由人
天命终不由人 2020-11-27 19:11

I have a widget that contains an iframe. The user can configure the url of this iframe, but if the url could not be loaded (it does not exists or the user does not have acce

6条回答
  •  臣服心动
    2020-11-27 19:33

    After the onload fires, you can scavenge the content of the iframe to see if it contains a usefull page or not. You'd have to make this browser specifuc unfortunately because they all display a different "page not found" message.

    For more info, take a look here at http://roneiv.wordpress.com/2008/01/18/get-the-content-of-an-iframe-in-javascript-crossbrowser-solution-for-both-ie-and-firefox/

提交回复
热议问题