SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Feb 2001
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im trying to use a .js file to store text that will be displayed in a small window. I tried to do a test in a regular window but i keep getting an error saying that my external variable is undefined. what am i doing wrong.
    Below are the two files.

    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    <SCRIPT LANUAGE="JavaScript" SRC="mytext.js"></SCRIPT>

    <SCRIPT LANUAGE="JavaScript" type="text/javascript">
    <!--
    var mytext = text;
    -->
    </SCRIPT>

    </head>

    <body bgcolor="#FFFFFF" text="#000000">
    <SCRIPT LANUAGE="JavaScript" >
    <!--
    document.write(mytext);
    -->
    </SCRIPT>


    </body>
    </html>

    mytext.js (External .js file)
    <!-- hide script from old browsers


    var text ="this is the text that should be inserted into the window whenever This source file is called lets see if it works";

    // end hiding script from old browsers -->


    please can someone help.

  2. #2
    SitePoint Member JohnP's Avatar
    Join Date
    Sep 1999
    Location
    Texas
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try taking the comments out of the .js file, and making it just the one line with your variable declaration:

    ---
    var text ="this is the text that should be inserted into the window whenever This source file is called lets see if it works";
    ---


  3. #3
    SitePoint Wizard
    Join Date
    Jan 2001
    Location
    Milton Keynes, UK
    Posts
    1,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    John,

    leerie has solved this problem. He'd posted the query in another thread. He realised that he'd given the js file a .js.txt file extension.

    Shane

  4. #4
    SitePoint Member JohnP's Avatar
    Join Date
    Sep 1999
    Location
    Texas
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, OK. Thanks for letting me know.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •