views:

230

answers:

2

Hi,

i am developing a firefox extension, On a client side of a web page i add a link and on clicking the link i intend to open a window where it will allow the user to type in text. when i click the link, it opens the window but it won't allow me to write to it.

e.g. ww.document.write('<div id = "textDiv">') ; here it gives me an error:

Error: uncaught exception: [Exception... "Security error" code: "1000" nsresult: "0x805303e8 (NS_ERROR_DOM_SECURITY_ERR)" location: "chrome://googbar/content/googbar.js Line: 272"]

and i open window using the following:

var ww = Components.classes[
 "@mozilla.org/embedcomp/window-watcher;1"].getService(Components.interfaces.nsIWindowWatcher);
var wm =Components.classes["@mozilla.org/appshell/window-mediator;1"]

calWindow = ww.openWindow(null,'calendarWindow',null, 'left =500, top = 190, width = 230, height = 220,titlebar = no', null);

The window that is opened is not an empty window, it contains the contents of the parent window. for e.g i open this window from wikipedia, the new window opened contains the wiki page on it. Can anyone help me please?

A: 

I'm not entirely clear what's causing this, but these two pages on MDC suggest that this may have been affected by changes in Firefox 3.0 to tighten up some security issues.

Although not a complete answer, this might put you on the right track for solving your problem. If not, give us some more details about what you're trying to do.

Tim
with my extension i try to add a link, which on clicking opens a window and in this window the user can type in the text which will be saved in SQLite. So its like allowing user to annotate on the web page.
fftoolbar
I even tried window.open which i suppose does the same thing but it give me the same error. This link that i am talking about is added on the Web page (Not as a tool bar)on the client side.
fftoolbar
A: 

1) nsIWindowWatcher.openWindow's second argument is URL. 'calendarWindow' isn't. A google result from mozillazine suggests that passing '' magically makes document.write work, I didn't check.

2) I would try setting document.body.innerHTML instead of using document.write(). I think document.write() is a poor API that should only continue to exist for compatibility.

3) Anyway, in your case I don't see why you need to open a whole browser window just to put some simple HTML there. Create a XUL dialog, put it in your extension and open it (using window.open('chrome://....', '', 'chrome')). It's also much faster to open.

Nickolay
Thanks Nick for the suggestion. The last was did wonders for me. Thanks again.
fftoolbar