iLTC Home
Bookmark iLTC!
iLTC Google Boards

Google Groups
Receive The Code in Email!



Categories

Perl
  • Perl Tutorials Beginners

    Javascript
  • Javascript Tutorials
  • Javascript Tutorials Beginners

    HTML
  • HTML Tutorials



  • Perl with cheese...
    20,086

    iLoveTheCode.com
    Javascript > Javascript Tutorials How To Easy > Make a String into a Link in Javascript

    Make a String into a Link in Javascript



    j="This is a good time.";

    j=j.link('http://google.com');

    document.write(j);

    Which Prints:
    This is a good time.

    -We created a variable and named it j because the letter j is typing friendly.
    -We applied Javascript's built-in link method to our j string.
    -We put the url we wanted for the link in quotation marks and parenthesis.
    -We stored those results back into j.
    -We used Javascript's built-in document.write to print to the browser.


    We could have also written this a little differently, like so:

    j="This is a good time.";

    document.write(j.link('http://google.com'));


    ADVANCED: You can also apply more than one method to the string:

    j="This is a good time.";
    j=j.italics().bold().link('http://google.com');
    document.write(j);

    or

    j="This is a good time.";
    document.write(j.italics().bold().link('http://google.com'));



    Free Copy and Paste Javascript Code:

    <script type="text/javascript">
    <!--

    i="This is a good time.";
    j=i.link('http://google.com');

    document.write(i);
    document.write(j);
    document.write(i.link('http://google.com'));

    -->
    </script>


    Resources:
    A nice offsite Tutorial at JavaScript Kit
    Sun Javascript Documentation on Strings

    Bold Text in Javascript
    Italics in Javascript
    Redirect in Javascript
    Change Fonts in Javascript
    Change Font Size in Javascript

    HTML Tags
    HTML Color Chart
    HTML Codes



    Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
    Previous Article: Javascript Italics Text
    Next Article: Make Text Blink Using Javascript





    Struts 2 in ActionStruts 2 in Action

    Don Brown, Chad Da...

    New $29.69

    CSSCSS

    Eric Meyer

    New $29.69

    Pro CSS and HTML Design ...Pro CSS and HTML Design Patterns

    Michael Bowers

    New $29.69

    CSSCSS

    David McFarland

    New $23.09

    JavaScriptJavaScript

    David Flanagan

    New $31.49

    Head First HTML with CSS...Head First HTML with CSS & XHTML

    Eric Freeman, Elis...

    New $26.39

    DojoDojo

    Matthew A. Russell...

    New $26.39

    Creating Web SitesCreating Web Sites

    Matthew MacDonald

    New $19.77

    jQuery in ActionjQuery in Action

    Bear Bibeault, Yeh...

    New $26.39


    Of Interest:
  • Passing a Variable or Value to a Subroutine in Perl
  • Making a Directory Using mkdir in Perl
  • And, Or, Equal, Not Equal, Greater Than, Less Than in Perl
  • Write a FOR LOOP in Perl
  • Javascript Focus Form Field
  • Create a Function in Javascript
  • Use onLoad in Body Tag with Javascript
  • Javascript Slice - Use Slice to Get Items from an Array in Javascript
  • Make Strikethrough Text Using HTML
  • HTML Tags
  • HTML Color Chart
  • HTML Title Tag

  • More Articles:
  • Use the Perl PRINT FUNCTION
  • Finding the Length (Index Numbers) of an Array in Perl
  • Create a Subroutine in Perl
  • Get the Length of a Word or String in Perl
  • onClick Javascript
  • Javascript Change Font Size
  • Javascript Alert
  • Javascript Change Fonts
  • Javascript Italics Text
  • Get Formatted Time in Javascript
  • Call your Function in Javascript
  • Javascript Reverse - Use Reverse on Items in an Array in Javascript
  • HTML Underline Text
  • HTML Color Chart
  • Make a Line Return Using HTML
  • Make Italic Text Using HTML

  • Search iLTC w/ Google





    Recent Articles

  • Javascript Focus Form Field
  • Javascript Lowercase Text
  • Javascript Uppercase Text
  • Javascript Superscript Text
  • Javascript Subscript Text
  • Make Text Blink Using Javascript
  • Make a String into a Link in Javascript
  • Javascript Italics Text
  • Javascript Bold Text
  • Javascript Redirect
  • HTML Frames
  • HTML Color Chart
  • HTML Link
  • Javascript Status Bar








  • Perl Programming - Javascript Programming - Maybe Some PHP - Free Scripts - ILoveTheCode
    All Content © 2006 iLoveTheCode.com


    Contact Chris | About this Site


    316,826
    Counter by iLoveTheCode.com


    Last Modified: Sunday, 09-Jul-2006 01:40:46 EDT