iLTC Home
Bookmark iLTC!

Categories

Perl
  • Perl Tutorials Beginners

  • Javascript
  • Javascript Tutorials
  • Javascript Tutorials Beginners

  • HTML
  • HTML Tutorials

  • Command Line
  • Command Line Tutorials

  • How Tos
  • Other Tips and Tricks



  • #!/usr/bin/perl
    2210960

    iLoveTheCode.com

    Opening an Alert Box in Javascript

    alert() is a built-in Javascript method.

    A little tricky here with the quotation marks (See IMPORTANT note below).

    Put what you want the alert to display in single or double quotation marks.

    Example in a script:

    alert("Do Not Leave My Site!");

    Example in a link:

    <a href="http://google.com" onClick="alert('You are going to Google!');return true">Google</a>


    When passing a varible to alert(), use no quotation marks at all.

    var ko = "Google me.";
    alert(ko);

    Quotation marks around ko would display the word ko rather than the value of the variable ko.


    IMPORTANT:

    -In a script: Backslash out quotes in your display text or make them opposite the containing marks. Examples:

    alert("He said \"hey man\"");
    alert('He said \'hey man\'');
    alert("He said 'hey man'");
    alert('He said "hey man"');

    alert("Don't leave my site");
    alert('Don\'t leave my site');

    -In a link: Backslash out quotes in display text. Example:

    <a href="#" onClick="alert('Doesn\'t go to Google');return true">Google</a>


    You can look at that as being complicated or you can see it as flexible.


    Copy and Paste Javascript (two ways to use):

    In a link:

    <a href="http://google.com" onClick="alert('You are going to Google!');return true">Google</a>

    In a script:

    <script type=text/javascript>
    <!--
    alert("Don't Leave My Site!");
    -->
    </script>


    Note: When using in a link, the "return true" means go to the link that is being clicked on. "return false" stops the browser from going to the link.


    Alert Box - See in Action (new window)




    Previous Article: Opening a REMOTE WINDOW in Javascript
    Next Article: Passing an Argument or Variable to a Javascript






    Search iLTC w/ Google




    Recent Articles

  • HTML Font Code
  • Javascript and CSS - Easy Pop Up Help Balloons
  • Use OnMouseOver in Javascript
  • Use onMouseOut in Javascript
  • Use innerHTML to Change Text on a Page
  • Renaming a File with Perl's RENAME Function
  • PRINT to Browser with document.write Command in Javascript
  • Passing an Argument or Variable to a Javascript
  • Opening an Alert Box in Javascript
  • Opening a REMOTE WINDOW in Javascript
  • OPEN and WRITE a Data File in Perl
  • OPEN and READ a Data File in Perl
  • Mimic Typing from a Textfield in a Textarea with Javascript
  • Javascript Reset Form








  • Perl Programming - Javascript Programming - HTML Code - Mac Unix Command Line - Maybe Some PHP - Free Scripts - ILoveTheCode
    All Content © 2006-2009 iLoveTheCode.com


    Contact Chris | About this Site


    2210171
    Counter by iLoveTheCode.com


    Last Modified: Monday, 09-Feb-2009 04:21:53 EST



    Hosted as well :)
    Home-brewed logo - 1997