DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Mozilla: Getting Editor From An Iframe

  • submit to reddit
        Seems like getting an editor from a designMode/contenteditable iframe is harder than it should be in firefox:

First the docshell:
const Ci = Components.interfaces;
const Cc = Components.classes;

var editframe = window.frames[0];
var editdoc = editframe.document;

var docshell = editframe.QueryInterface(Ci.nsIInterfaceRequestor)

And now the editor (expanded)
var editor = editframe.QueryInterface(Ci.nsIInterfaceRequestor)

// -- OR --
var editor = docshell.QueryInterface(Ci.nsIInterfaceRequestor)

// If you want: