SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member CybJunior's Avatar
    Join Date
    Dec 2005
    Location
    fgfg
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Including a js inside the js script without html tags being generated.

    Hi,
    I have this in html, but is there any way to include an url from another script without using html?

    <script src="http://someUrl.com" charset="utf-8" type="text/javascript"></script>

  2. #2
    SitePoint Member CybJunior's Avatar
    Join Date
    Dec 2005
    Location
    fgfg
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i know there is way to do it like this:

    Code:
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = 'snip.js';
    document.getElementsByTagName('head')[0].appendChild(script);
    But i dont need html. i just cant find a synonym for src in javascript

  3. #3
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't understand your question - what is wrong with the second method you posted?

  4. #4
    SitePoint Member CybJunior's Avatar
    Join Date
    Dec 2005
    Location
    fgfg
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i have an ajax script which is a part of plugin for FireFox, so i don't think that html can be used there

    Code:
    <script src="http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=YahooDemo&amp;output=json&amp;results=2&amp;callback=grs.pongSearch&amp;query=hello" charset="utf-8" type="text/javascript"></script>
    this is yahoo API it returns a callback function. Then i get what i need from the response using:
    <script src="http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=YahooDemo&amp;output=json&amp;results=2&amp;callback=grs.pongSearch&amp;query=hello" charset="utf-8" type="text/javascript"></script>

    this is yahoo API it returns a callback function.

    Code:
    <script type="text/javascript">
    var grs =
    {
      
      pongSearch : function(z)
      {  
          var res = z.ResultSet.totalResultsAvailable;
          alert(res);
      }
    };
    </script>
    So is there any way to do it?

  5. #5
    SitePoint Member CybJunior's Avatar
    Join Date
    Dec 2005
    Location
    fgfg
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone???
    There must some way like in php for example its include('file.php');
    I really need help!

  6. #6
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No. There is no way in javascript to call another javascript file.


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
  •