SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    linking from within javascript.....

    Can I link from an external .js to another? If so, how do I do it.

    I'm sure I've seen this topic before, but I took no notice then as I didn't need it!!

    And I've been trying to search for it but no luck.
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You mean include one JS file from within another? No. Closest you will get is
    Code:
    document.write('<scr'+'ipt src="otherJS.js" type="text/javascript"></scr'+'ipt>');
    or
    Code:
    function addScript( src )
    {
        var s = document.createElement( "script" );
        s.setAttribute( "type", "text/javascript" );
        s.setAttribute( "src", src );
        document.getElementsByTagName( "head" )[0].appendChild( s );
    }
    
    addScript( "otherJS.js" );
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  3. #3
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    I think the first is good for me.

    Thanks Beetle, I didn't think about splitting the '<script>'.

    It's not for a dynamic page, just for loading different variables depending on the top.location at loading.

    I presume this will work with an 'if'.
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if


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
  •