#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2001
    Posts
    910
    Rep Power
    0

    Show Text Function in Javascript


    I have a page, what I would like to do is the following:

    1) Create a javascript file that would show text that is in the script, such as "This is The News" would be displayed when script is run.

    2) <script language="JavaScript1.2" src="new.js"></script> Use this type of reference in the page anywhere, and have the text shown.

    Is this all possible? If so please provide a sample script and definition.

    Thanks

    Tim
  2. #2
  3. mod_dev_shed
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    14,817
    Rep Power
    1099
    news.js
    ----------
    document.write('This is The News');

    Include it like you have in your post.
    # Jeremy

    Explain your problem instead of asking how to do what you decided was the solution.
  4. #3
  5. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
    1) Put the HTML in one long string in your .js file, assigned to somevariablename. You can use one of the convertors found here.
    2) Be sure the <script....src="... tags are in the page <head>er.
    3) Embed the following in your document, at the very spot where the HTML would have been hardcoded (if you'd done it the usual way):

    <script type="text/javascript" language="javascript">

    document.write(somevariablename);

    </script>

    That's it!

IMN logo majestic logo threadwatch logo seochat tools logo