Skip to content

Instantly share code, notes, and snippets.

@anantn
Created January 1, 2013 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anantn/4430391 to your computer and use it in GitHub Desktop.
Save anantn/4430391 to your computer and use it in GitHub Desktop.
Creating an iframe in Firefox extension code
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");
}
@gokul01it
Copy link

Could you please answer me the below queries?

How use this js file in webpages?
How to create extension out of it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment