Hi Matthew
I dont think that this is a case , here is example:
----XUL---
<label value="Put your XUL here!" id="iddd"
onclick="
* p.MyFuction();*
"
/>
-------
----JavaScript---
var p = {
element1 : "" ,
Initial : function(){
this.element1 = document.getElementById("iddd");
},
MyFuction : function(){
this.element1.value="some text";
}
}
*window.addEventListener("load", p.Initial, true); *
-------
In this example I use p.Initial in proper time, but still nothing happens
when click on label!
On Sun, Oct 26, 2008 at 1:35 AM, Matthew Wilson <
[EMAIL PROTECTED]> wrote:
> In example 2, you call p.Initial() too early. The document has not yet been
> fully loaded, so document.getElementById("iddd") does not return anything.
>
> Matthew
>
> joe ertaba wrote:
>
>> 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) <[EMAIL
>> PROTECTED]<mailto:
>> [EMAIL PROTECTED]>> 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
>> [email protected] <mailto:[email protected]>
>> https://www.mozdev.org/mailman/listinfo/project_owners
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Project_owners mailing list
>> [email protected]
>> https://www.mozdev.org/mailman/listinfo/project_owners
>>
>
> _______________________________________________
> Project_owners mailing list
> [email protected]
> https://www.mozdev.org/mailman/listinfo/project_owners
>
_______________________________________________
Project_owners mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/project_owners