I expect that this would have to be loaded from a signed jarfile
in order for the enablePrivilege call to successfully show the
user a dialog from which they could decide whether or not to
grant the privilege. You might get a better answer in the
security newsgroup.
John.
Boris Tubak wrote:
>
> im trying to execute the code from below and i get this:
>
> JavaScript error:
> line 0: uncaught exception: enablePrivilege not granted
>
> without the enablePrivilege(), next line fails saying its refused access to
> XPConnect.
> does anyone know whats wrong with this code? is it because the code is
> embedded in html?
> i'm loading the .html from below into a <browser> widget.
>
> -boris
>
> /***************************************************************************
> *******************************************/
>
> <HTML>
> <body topmargin=0 leftmargin=0 link="#0000FF" vlink="#666666"
> text="#333333">
>
> <script language="javascript">
>
> function toOpenWindowByType( inType, uri )
> {
>
> netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
>
> var v1 =
> Components.classes['@mozilla.org/rdf/datasource;1?name=window-mediator'];
> var windowManager = v1.getService();
> var windowManagerInterface =
> indowManager.QueryInterface( Components.interfaces.nsIWindowMediator);
> var topWindow = windowManagerInterface.getMostRecentWindow( inType );
>
> if ( topWindow )
> {
> topWindow.focus();
> }
> else
> {
> window.open(uri, "_blank",
> "chrome,menubar,toolbar,resizable,scrollbars");
> }
> }
>
> </script>
>
> <a href="chrome://navigator/skin/newmail.htm"
> onClick="toOpenWindowByType('mail:3pane',
> 'chrome://messenger/content/messenger.xul');"><IMG SRC="newmail.gif"
> border=0></a>
> </body>
> </HTML>