[Project_owners] Javascript!

joe ertaba belaviyo at gmail.com
Sat Oct 25 14:13:00 PDT 2008


There is a problem with this method which I cant find out, here is example:

Example 1 (This example works fine)

--JS code---

var p = {
    element1 : "" ,
    Initial : function(){
        this.element1 = document.getElementById("iddd");
    },
    MyFuction : function(){
        this.element1.value="some text";
    }
}

-----
-XUL code----

<label value="Put your XUL here!" id="iddd"
onclick="
 *p.Initial();
*
*p.MyFuction();*
 "
 />
-----

Example 2:

--JS code---

var p = {
    element1 : "" ,
    Initial : function(){
        this.element1 = document.getElementById("iddd");
    },
    MyFuction : function(){
        this.element1.value="some text";
    }
}

*p.Initial();
window.addEventListener("load", p.MyFuction, true); *
-----
-XUL code----

<label value="Put your XUL here!" id="iddd"/>
-----

The second example DOES NOT work!






On Sat, Oct 25, 2008 at 8:23 PM, Roberto Bouzout (tito) <zilla at nxuy.com>wrote:

> You are welcome!  :)
>
> joe ertaba wrote:
>
>> I find out that when I use initial function to initialize var then it
>> works!
>>
>> Thanks for your help
>>
>>
>>  _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> https://www.mozdev.org/mailman/listinfo/project_owners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mozdev.org/pipermail/project_owners/attachments/20081026/248608d1/attachment.html>


More information about the Project_owners mailing list