[英]SelectionContext in iFrame - Permission denied to access property ‘getSelection’
在帶有 iFrame 的網站上,如果我通過上下文菜單內容腳本繞道而行,則很難檢索所選文本。
在 main.js 中,我定義了一個帶有SelectionContext
的上下文菜單項,在其onMessage
方法中,會通知page-mod
contentScriptFile
。 然后,該腳本應該通過getSelection().toString()
獲取選擇。
但是當在 iFrame 中時,此方法要么返回空字符串,要么 getSelection 為空。 嘗試通過父窗口( parent.getSelection()
)獲取選擇會導致錯誤(可能是由於parent.getSelection()
策略):
控制台錯誤:消息:錯誤:訪問屬性“getSelection”的權限被拒絕
任何人都知道如何解決這個問題? 謝謝
指定attachTo
方法是我的解決方案 - 我需要:
attachTo: ['top']
感謝克里斯托·帕普拉斯! (見問題下的評論)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.