Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Javascript alert issue.  (Read 3017 times)

0 Members and 1 Guest are viewing this topic.

Google

    Topic Starter


    Mentor

    Thanked: 2
    • Certifications: List
    • Experience: Experienced
    • OS: Windows 7
    Javascript alert issue.
    « on: November 28, 2009, 06:59:20 PM »
    Why does this work?
    Code: [Select]
    <html>
    <head>
    <script type="text/javascript">
    function ale_rt()
    {
    alert("I am an alert box!");
    }
    </script>
    </head>
    <body>

    <input type="button" onclick="ale_rt()" value="Show alert box" />

    </body>
    </html>
    But not this?
    Code: [Select]
    <html>
    <head>
    <script type="text/javascript">
    function alert()
    {
    alert("I am an alert box!");
    }
    </script>
    </head>
    <body>

    <input type="button" onclick="alert()" value="Show alert box" />

    </body>
    </html>

    Google

      Topic Starter


      Mentor

      Thanked: 2
      • Certifications: List
      • Experience: Experienced
      • OS: Windows 7
      Re: Javascript alert issue.
      « Reply #1 on: November 28, 2009, 07:13:33 PM »
      Same with the confirm command.

      kpac

      • Web moderator
      • Moderator


      • Hacker

      • kpac®
      • Thanked: 184
        • Yes
        • Yes
        • Yes
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 7
      Re: Javascript alert issue.
      « Reply #2 on: November 29, 2009, 04:56:20 AM »
      You cannot give any function the same name as a predefined JS function, like alert, confirm, and a bunch more.

      Google

        Topic Starter


        Mentor

        Thanked: 2
        • Certifications: List
        • Experience: Experienced
        • OS: Windows 7
        Re: Javascript alert issue.
        « Reply #3 on: November 29, 2009, 09:27:25 AM »
        Ok, yea I guessed that might be it, I'll have to find a list of predefined functions then...

        kpac

        • Web moderator
        • Moderator


        • Hacker

        • kpac®
        • Thanked: 184
          • Yes
          • Yes
          • Yes
        • Certifications: List
        • Computer: Specs
        • Experience: Expert
        • OS: Windows 7
        Re: Javascript alert issue.
        « Reply #4 on: November 29, 2009, 10:45:49 AM »
        You'll be able to guess them after a while. Here: http://javascript.about.com/library/blreserved.htm

        Google

          Topic Starter


          Mentor

          Thanked: 2
          • Certifications: List
          • Experience: Experienced
          • OS: Windows 7
          Re: Javascript alert issue.
          « Reply #5 on: November 29, 2009, 01:31:01 PM »
          Alright thanks. Another question... how do I go about actully practicing Javascript? Like I'm going through the tutorial at w3schools, but that doesn't mean I actually "know it" or can use it efficiently.

          I need some way to practice it... any suggestions?

          kpac

          • Web moderator
          • Moderator


          • Hacker

          • kpac®
          • Thanked: 184
            • Yes
            • Yes
            • Yes
          • Certifications: List
          • Computer: Specs
          • Experience: Expert
          • OS: Windows 7
          Re: Javascript alert issue.
          « Reply #6 on: November 29, 2009, 02:14:13 PM »
          Ahhh......

          * thinks *

          Do you ever go to a site and wonder, how did they do that?
          Well the best way to learn is to cheat - look at source code of the site. Usually CTRL+U.

          Google

            Topic Starter


            Mentor

            Thanked: 2
            • Certifications: List
            • Experience: Experienced
            • OS: Windows 7
            Re: Javascript alert issue.
            « Reply #7 on: November 29, 2009, 02:15:19 PM »
            haha okay