Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

gokul01it commented Apr 21, 2015

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
You can’t perform that action at this time.