SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2010
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question help me with var in javascript ???

    I have a 1.htm file
    =========
    <html>
    var a=1;

    <!---- i want to get var a=1 . but don't give var a into <script>...</script>---->
    <script src="1.js"></script>
    </html>

    In 1.js file writed:
    ===========
    ..............
    alert(a);

    I want to call var a from 1.htm file to 1.js
    Can everyone help me !
    Thanks all very much !!!

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2011
    Location
    Dartmouth, MA, USA
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to put that statement between script tags, then follow that with the inclusion of your other JavaScript file:

    Code HTML4Strict:
    <html>
    <head>
    <script type="text/javascript">
      var a = 1;
    </script>
    <script src="1.js"></script>
    </head>
    <body>
    ...
    </body>
    </html>


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
  •