why does this combination of function not work?

Discussion in 'Javascript' started by bob, Aug 21, 2003.

  1. bob

    bob Guest

    Hi,

    This script executes only the first function (window.onload) but not the
    second. I don't understand why. See the code:

    <SCRIPT LANGUAGE=JAVASCRIPT>
    function window.onload()
    { a=1
    document.writeln("<pre>")
    document.writeln(a)
    document.writeln("</pre>") }

    function test()
    {a=2
    document.writeln("<pre>")
    document.write(a)
    document.writeln("</pre>") }
    document.onclick=test()
    </SCRIPT>

    Thanks
    bob
     
    bob, Aug 21, 2003
    #1
    1. Advertising

  2. bob

    steve stevo Guest

    try

    document.onclick = test;

    "bob" <> wrote in message news:bi1se0$ch9$...
    > Hi,
    >
    > This script executes only the first function (window.onload) but not the
    > second. I don't understand why. See the code:
    >
    > <SCRIPT LANGUAGE=JAVASCRIPT>
    > function window.onload()
    > { a=1
    > document.writeln("<pre>")
    > document.writeln(a)
    > document.writeln("</pre>") }
    >
    > function test()
    > {a=2
    > document.writeln("<pre>")
    > document.write(a)
    > document.writeln("</pre>") }
    > document.onclick=test()
    > </SCRIPT>
    >
    > Thanks
    > bob
    >
    >
     
    steve stevo, Aug 21, 2003
    #2
    1. Advertising

  3. bob

    bob Guest

    thanks
     
    bob, Aug 21, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jblazi
    Replies:
    5
    Views:
    436
    jblazi
    Aug 16, 2004
  2. Horace Nunley

    why why why does function not work

    Horace Nunley, Sep 27, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    465
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Sep 27, 2006
  3. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    913
    Mark Rae
    Dec 21, 2006
  4. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,008
    Smokey Grindel
    Dec 2, 2006
  5. Tarun
    Replies:
    5
    Views:
    396
    Tarun
    Jul 14, 2005
Loading...

Share This Page