[Project_owners] privileged and unprivileged javascript prototypes

Neil neil at parkwaycc.co.uk
Mon Nov 7 10:12:37 EST 2005


Eric Jung wrote:

>So what I tried was:
>
>In XUL overlay:
>  window.addEventListener("load", function() {myext.init();}, false);
>
>In myext.js:
>
>  var myext = {
>
>    init : function() {
>      document.getElementById("appcontent")
>        .addEventListener("load", this.pageLoad, true);
>    },
>
>    pageLoad : function() {
>      String.prototype.foo = "foo";
>    }
>  };
>
>Yet this attribute/property still doesn't seem available in HTML pages. I suspect I must somehow get the Window object in pageLoad() and call String.prototype.foo on that. Is that correct?
>  
>
Correct, your event handler is simply modifying your window's String 
prototype. You probably want 
event.target.defaultView.String.prototype.foo = "foo";


More information about the Project_owners mailing list