Created
January 1, 2013 22:04
-
-
Save anantn/4430391 to your computer and use it in GitHub Desktop.
Creating an iframe in Firefox extension code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (Components && Components.classes) { | |
// This means we are in a Firefox extension. | |
var appShell = Components.classes["@mozilla.org/appshell/appShellService;1"] | |
.getService(Components.interfaces.nsIAppShellService); | |
// hiddenDoc will now point to a regular DOM document. | |
var hiddenDoc = appShell.hiddenDOMWindow.document; | |
// Create an iframe. | |
let iframe = hiddenDoc.createElementNS("http://www.w3.org/1999/xhtml", "iframe"); | |
iframe.setAttribute("mozframetype", "content"); | |
hiddenDoc.documentElement.appendChild(iframe); | |
// Load a page in it. | |
iframe.setAttribute("src", "http://google.com"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could you please answer me the below queries?
How use this js file in webpages?
How to create extension out of it?