我想添加一個iframe到第一個孩子與火狐插件之前的當前文檔的正文。Firefox插件:如何在頁面加載基於當前域名插入iFrame
我在做什麼:
- 附加組件讀取當前的URL域名
- 發送域名個人服務器
- 服務器然後插入iframe的成體填入相應的內容
我閱讀了所有可能的Mozilla文檔,但是我不會找到任何說明將HTML元素插入當前網頁的內容。我是Firefox開發新手。
讀取域名:
var domain = document.domain; //not working
我嘗試下面的代碼插入iframe中:
var pageMod = require("sdk/page-mod");
var ifrm =document.createElement('<iframe src=http://www.example.com/addon></iframe>');
pageMod.PageMod({
include: "*.org",
contentScript: 'document.body.insertBefore(ifrm, document.body.firstChild);'
});
問題:
- 是否有可能與Firefox插件,或者我應該切換到Firefox擴展
- 如何將iframe插入到bod y
這可能不是你的問題的完整解決方案,但你在做錯誤的方式的createElement。嘗試像'var ifrm = document.createElement('iframe'); ifrm.setAttribute('src','http://www.example.com/addon'); document.body.insertBefore(ifrm,document.body.firstChild);' –