SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast spacebass5000's Avatar
    Join Date
    Jun 2000
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I include a Javascript file in a Javascript file?

    I am looking to nest an include for one javascript file in another, how do I do this
    wtf, SitePoint rocks!

    Great hosting I use and recommend:
    LW | HG


  2. #2
    SitePoint Zealot yacka's Avatar
    Join Date
    Aug 2006
    Posts
    124
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think javascript provides a means for importing a script inside another. I'd love to be shown wrong. However, you could use a server side include to pull in the contents of another file. Maybe something like <!--#include file="nestedscript.js"-->?

    What are you trying to do? There may be a better approach.

  3. #3
    SitePoint Enthusiast spacebass5000's Avatar
    Join Date
    Jun 2000
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the input. in a nutshell, i am building a file dynamically. this file simply holds a function to preload some files and then a list of the files to be preloaded. this is for a Joomla menu component. trying to make it scalable via the back-end without any hand-editing.
    wtf, SitePoint rocks!

    Great hosting I use and recommend:
    LW | HG


  4. #4
    SitePoint Member
    Join Date
    Sep 2006
    Location
    Calarasi, Romania
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    although it doesn't make much sense, i guess you could "include" another JS by using something like this:
    Code:
    document.write('<script type="text/javascript" src="new_script.js"></script>');
    v-wdd.net/blog/

  5. #5
    SitePoint Enthusiast spacebass5000's Avatar
    Join Date
    Jun 2000
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that'll work...
    wtf, SitePoint rocks!

    Great hosting I use and recommend:
    LW | HG


  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    See http://javascript.about.com/library/bladdjs.htm for how to create a Javascript function for adding Javascript to an existing page where you can't use document.write
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


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
  •