How to tailor the path of an external js file?

Discussion in 'Javascript' started by cirillo curiosone, Jul 28, 2004.

  1. Hi all!

    here'm my problem.

    In a parametric code i have to select which js file to load
    but, even if the path string composition is right, the js file is not
    executed.
    See below:

    <head>
    .......
    <script type="text/javascript">
    var gal_num=parent.scelta;
    var
    gal_par_path=gal_path[gal_num]+"gallery"+gal_num+"/g"+gal_num+"_par.js";

    </script>
    <script type="text/javascript" src=gal_par_path></script>
    </head>

    I have tested the gal_par_path in the body, it looks right!
    On the contrary, the file is executed if, instead of the local variable
    i write it entirely.

    Thanks all for any help.
    cirillo curiosone, Jul 28, 2004
    #1
    1. Advertising

  2. cirillo curiosone

    Harag Guest

    On Wed, 28 Jul 2004 12:36:07 +0200, cirillo curiosone
    <> wrote:

    >
    >Hi all!
    >
    >here'm my problem.
    >
    >In a parametric code i have to select which js file to load
    >but, even if the path string composition is right, the js file is not
    >executed.
    >See below:
    >
    > <head>
    > .......
    > <script type="text/javascript">
    > var gal_num=parent.scelta;
    > var
    >gal_par_path=gal_path[gal_num]+"gallery"+gal_num+"/g"+gal_num+"_par.js";
    >
    > </script>
    > <script type="text/javascript" src=gal_par_path></script>


    The above line is HTML not javascript... try putting:

    document.write('<script type="text/javascript" src=' + gal_par_path +
    '></script>')

    between the first <script> & </script> tags.

    Not sure if this will work as I've never done anything like that.

    HTH.

    Al.


    > </head>
    >
    >I have tested the gal_par_path in the body, it looks right!
    >On the contrary, the file is executed if, instead of the local variable
    >i write it entirely.
    >
    >Thanks all for any help.
    >
    Harag, Jul 28, 2004
    #2
    1. Advertising

  3. Harag wrote:

    > On Wed, 28 Jul 2004 12:36:07 +0200, cirillo curiosone
    > <> wrote:
    >
    > >
    > >Hi all!
    > >
    > >here'm my problem.
    > >
    > >In a parametric code i have to select which js file to load
    > >but, even if the path string composition is right, the js file is not
    > >executed.
    > >See below:
    > >
    > > <head>
    > > .......
    > > <script type="text/javascript">
    > > var gal_num=parent.scelta;
    > > var
    > >gal_par_path=gal_path[gal_num]+"gallery"+gal_num+"/g"+gal_num+"_par.js";
    > >
    > > </script>
    > > <script type="text/javascript" src=gal_par_path></script>

    >
    > The above line is HTML not javascript... try putting:
    >
    > document.write('<script type="text/javascript" src=' + gal_par_path +
    > '></script>')
    >
    > between the first <script> & </script> tags.
    >
    > Not sure if this will work as I've never done anything like that.
    >
    > HTH.


    Thanks Harag,

    i tried but it doesn't seem to work.
    I think there should be one way, at least, to load different values for one
    or more variables for different external files.

    Let's see if anyone else can help me...
    thanks again.
    cirillo curiosone, Jul 28, 2004
    #3
  4. cirillo curiosone

    Harag Guest

    On Wed, 28 Jul 2004 14:54:44 +0200, cirillo curiosone
    <> wrote:

    >Harag wrote:
    >
    >> On Wed, 28 Jul 2004 12:36:07 +0200, cirillo curiosone
    >> <> wrote:
    >>
    >> >
    >> >Hi all!
    >> >
    >> >here'm my problem.
    >> >
    >> >In a parametric code i have to select which js file to load
    >> >but, even if the path string composition is right, the js file is not
    >> >executed.
    >> >See below:
    >> >
    >> > <head>
    >> > .......
    >> > <script type="text/javascript">
    >> > var gal_num=parent.scelta;
    >> > var
    >> >gal_par_path=gal_path[gal_num]+"gallery"+gal_num+"/g"+gal_num+"_par.js";
    >> >
    >> > </script>
    >> > <script type="text/javascript" src=gal_par_path></script>

    >>
    >> The above line is HTML not javascript... try putting:
    >>
    >> document.write('<script type="text/javascript" src=' + gal_par_path +
    >> '></script>')
    >>
    >> between the first <script> & </script> tags.
    >>
    >> Not sure if this will work as I've never done anything like that.
    >>
    >> HTH.

    >
    >Thanks Harag,
    >
    >i tried but it doesn't seem to work.
    >I think there should be one way, at least, to load different values for one
    >or more variables for different external files.
    >
    >Let's see if anyone else can help me...
    >thanks again.
    >


    oops forgot....

    to save getting the error when you click the 2nd paragraph to run the
    function in the 2nd file then change the clicking lines to the
    following:

    <p><span onClick="if (window.a1) a1();">Click Me for Func.1</span>
    <p><span onClick="if (window.a2) a2();">Click Me for Func.2</span>
    Harag, Jul 28, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Scott Allen
    Replies:
    8
    Views:
    10,907
    Scott Allen
    May 2, 2004
  2. Replies:
    1
    Views:
    574
    Oliver Wong
    Jul 13, 2006
  3. Kyle
    Replies:
    2
    Views:
    235
  4. \A_Michigan_User\

    Various path/path/files.asp all #include this 1 file

    \A_Michigan_User\, Jul 10, 2005, in forum: ASP General
    Replies:
    1
    Views:
    225
    Jeff Cochran
    Jul 10, 2005
  5. Mellow Crow
    Replies:
    6
    Views:
    411
    Richard Cornford
    Nov 4, 2005
Loading...

Share This Page