Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 1 of 1
  1. #1
    Member
    Join Date
    Apr 2013
    Posts
    30
    Member #
    35925
    Hi Everybody!

    Good day
    I like to know some JavaScript definitions are following:


    try_catch_statement:

    <html>
    <head>
    <script type="text/javascript">
    var txt="";
    function message()
    {
    try
    {
    adddlert("Welcome guest!");
    }
    catch(err)
    {
    txt="There was an error on this page.\n\n";
    txt+="Error description: " + err.description + "\n\n";
    txt+="Click OK to continue.\n\n";
    alert(txt);
    }
    }
    </script>
    </head>

    <body>
    <input type="button" value="View message" onClick="message()" />
    </body>

    </html>

    Please see the codes above and give me the following answer:

    # What is “txt”? Why I should use this?
    # What is “There was an error on this page.\n\n”? What is .\n\n?
    # What is “txt+="Error description: " + err.description + "\n\n";” here? I mean
    txt+,
    Error description:,
    err.description and
    "\n\n"?
    # What is “onClick="message()” as well?



    throw_statement:

    <html>
    <body>
    <script type="text/javascript">
    var x=prompt("Enter a number between 0 and 10:","");
    try
    {
    if(x>10)
    {
    throw "Err1";
    }
    else if(x<0)
    {
    throw "Err2";
    }
    else if(isNaN(x))
    {
    throw "Err3";
    }
    }
    catch(er)
    {
    if(er=="Err1")
    {
    alert("Error! The value is too high");
    }
    if(er=="Err2")
    {
    alert("Error! The value is too low");
    }
    if(er=="Err3")
    {
    alert("Error! The value is not a number");
    }
    }
    </script>
    </body>
    </html>

    # What is “else if(isNaN(x))”? Why I should use it?

    No more, I am waiting for your kind response.

    Thank you.

  2.  


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 01:36 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com