SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    May 2000
    Location
    UK
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I need real help with this one guys!

    I have the following code for my users to place on their site, which displays some HTML from an external js file:

    Code:
    <SCRIPT LANGUAGE="javascript1.1" src="http://xnames.homepagenames.com/xnames2.js"></SCRIPT>
    That is all fine and very simple, but...

    I need to tell the js file to add a variable at certain places in the HTML code it creates. And that variable needs to be passed from the code above.

    I tried the following, but that didn't work:

    Code:
    <SCRIPT LANGUAGE="javascript1.1" SRC="http://xnames.homepagenames.com/xnames.js">
    var affid = "joelmoss";  
    </script>
    Can someone please help?
    Joel Moss
    ========================
    HomepageUniverse - Names, Tools & Hosting

  2. #2
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Define your variable in a separate script block before you call the external file...

    Code:
    <script language="javascript1.1">
    var affid = "joelmoss";  
    </script>
    <script language="javascript1.1" src="http://xnames.homepagenames.com/xnames.js">
    //external file
    </script>
    Wayne Luke
    ------------


  3. #3
    SitePoint Zealot
    Join Date
    May 2000
    Location
    UK
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, that works a treat!
    Joel Moss
    ========================
    HomepageUniverse - Names, Tools & Hosting

  4. #4
    SitePoint Addict
    Join Date
    Oct 2000
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quick common-sense note on "why" (re: above)...

    The browsers parse more or less top down, so it only makes sense that you'd need to create and set the variable before you call the script that uses it.


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
  •