Re: Basic Question



On May 24, 9:42 pm, "david.karr" <davidmichaelk...@xxxxxxxxx> wrote:
On May 24, 7:58 pm, "levinsont...@xxxxxxxxx" <levinsont...@xxxxxxxxx>
wrote:



On May 24, 1:08 am, Gregor Kofler <use...@xxxxxxxxxxxxxxx> wrote:

levinsont...@xxxxxxxxx meinte:

test = {}
test.hi = alert("hi");

hi gets the "result" of (window.)alert assigned. And before returning
this result the alert is being popped up. What you were supposedly
looking for is

test.hi = function() { alert("hi"); };

However in your onload listener this.hi won't do the trick (just like
now). It must be test.hi()

Gregor

--http://photo.gregorkofler.at:::Landschafts-und Reisefotografiehttp://web.gregorkofler.com:::meine JS-Spielwiesehttp://www.image2d.com ::: Bildagentur für den alpinen Raum

Hi Gregor,

Thanks for your answer.

So, instead of assigning a function to test.hi that popped up an
alert, I was actually assigning window.alert to test.hi?

I guess I still don't understand why the interpreter executed test.hi
first.

You didn't assign "window.alert" to "test.hi", you assigned
'window.alert("hi")'. There's a big difference. You can assign
functions to variables, but that's not what you did. You assigned the
RESULT of calling 'window.alert("hi")' to "test.hi". Obviously, at
the time of the assignment, it actually called 'window.alert("hi")',
displaying the alert box, and then assigning the (meaningless) result
of calling that function to the variable "test.hi".

You saw the "hi" alert before the other alert because the other alert
only would have executed on completion of window load.

Thanks David, that clears it up for me.
.



Relevant Pages

  • Re: Basic Question
    ... this result the alert is being popped up. ... I was actually assigning window.alert to test.hi? ... of calling that function to the variable "test.hi". ... only would have executed on completion of window load. ...
    (comp.lang.javascript)
  • Re: Activate TaskBar Browser From Application
    ... assigning actions to various users of my system. ... explorer taskbar flash if tfey have a new action assigned. ... That's the closest I can think of in terms of attracting the user's attention if his browser window is minimized. ... there is even a sound when the alert pops up. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Basic Question
    ... this result the alert is being popped up. ... However in your onload listener this.hi won't do the trick (just like ... I was actually assigning window.alert to test.hi? ...
    (comp.lang.javascript)
  • Re: Voicemail Message Recd 1 Wk Later
    ... >>> Don't believe everything verizon sales support tells you. ... >>> on my experience when this happens, I think the original VM alert gets ... >>> message you sent plus all of the backlogged messages. ... I have had the same issue in the store and when calling tech support they ...
    (alt.cellular.verizon)
  • Re: The following disk has low idle time...
    ... Object: PhysicalDisk ... I also did not get the alert this morning now. ... and that it appears to have stopped after the array finished building ... Calling an illegal alien an "undocumented worker" is like calling a ...
    (microsoft.public.windows.server.sbs)