簡體   English   中英

我怎么知道一個網站是否接受iframe?

[英]How do I know if a website accepts iframes?

我正在尋找一種檢查網站是否接受iframe(可能是通過X-Frame-options ?)的方法,但我什至無法在客戶端閱讀該信息。

如何檢查網站是否允許客戶端?

您可以使用“ X-Frame-Options ”選項從網址獲取標頭。
這將返回DENYSAMEORIGINALLOW-FROM

如果您嘗試從其他域在iframe中加載網址,則可以嘗試類似的操作。

//get the iframe object
var iframe = document.getElementById('Frame');


var iframeDocument;


    try{

        //cross browser solution to get the iframe document
        //of the iframe
        iframeDocument = iframe.contentDocument || iframe.contentWindow.document;

    }
    catch(error){

        alert(error);

    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM