How to tailor the path of an external js file?

C

cirillo curiosone

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.
 
H

Harag

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.
 
C

cirillo curiosone

Harag said:
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.
 
H

Harag

Harag said:
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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top