Forum Moderators: open

Message Too Old, No Replies

An event

Using a colon

         

Alternative Future

11:59 am on Aug 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi to the forum,

Can someone please tell me what the difference between using a colon and a period between the window and the onload event is.
window:onload = function(){
}

window.onload = function(){
}

TIA,

-gs

[edited by: Alternative_Future at 12:19 pm (utc) on Aug. 20, 2007]

daveVk

12:35 pm on Aug 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In the first case.
"window" is a label and "onload = function(){}" is a statement

In the second case
"window.onload = function(){}" is the statement and there is no label

In most cases the statements will do the same job as "onload" will likely resolve to "window.onload"

Use the second case, labels in most cases bad practice.

Alternative Future

12:39 pm on Aug 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks daveVK,

Do you have any references to this you could share? As my second question is, what is the difference between a label and the statement?
I think it is obvious and makes sense but I just require to get a better understanding of it :)

Again thanks,

-Gs

daveVk

2:57 am on Aug 21, 2007 (gmt 0)