![](/img/trans.png)
[英]Using JavaScript in a cross-domain iframe, trying to detect Top URL
[英]How to detect if Javascript is running in an cross-domain IFrame in Opera?
如何檢測JavaScript是否在Opera的跨域IFrame中運行? 如果我嘗試測試if(typeof iframe.parent.document === 'undefined')
Opera 12似乎給出了“未處理的錯誤: Security error: attempted to read protected
”,該Security error: attempted to read protected
無法捕獲在代碼中,從而中斷了執行。
你不能 但是,如果您的目標是防止其他域中的人將您的頁面嵌入到iframe中,則可以發送一個http標頭來防止這種情況。
https://developer.mozilla.org/zh-CN/docs/The_X-FRAME-OPTIONS_response_header
大多數現代瀏覽器都支持它。 它允許您指定允許哪些網站將您的頁面嵌入iframe。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.