Jump to content

Path in Java Script .JS file


mrkhan
 Share

Recommended Posts

Hello,

i am trying to solve one issue from 2 days but no luck. 

i am developing one project in PW and its working perfect as always but issue is in footer file i am using one JS file as bellow

<script src="<?php echo $config->urls->templates?>assets/js/script.js"></script>

file load but script.js use few other files as bellow

include('js/jquery.easing.1.3.js');

these files are not loading , i have copied the JS folder in root and Home page start working but when i goto sub pages JS again stop working.

issue is with JS path.

how to fix that ?

Thanks

Link to comment
Share on other sites

There's no include() function in javascript. This is what you want:

<script src="<?php echo $config->urls->templates?>assets/js/jquery.easing.1.3.js"></script>
<script src="<?php echo $config->urls->templates?>assets/js/script.js"></script>
Link to comment
Share on other sites

Hello

yes i saw this function which is loading javascript files

function include(scriptUrl) {
    document.write('<script src="' + scriptUrl + '"></script>');
}

and after in same JS file called files like this

include('js/jquery.easing.1.3.js');

how to add assets path in JS file ?

Thanks

 
 
Link to comment
Share on other sites

Hello LostKobrakai,

thanks for reply but its not working. i think site/templates/  is not proper path.

but if i change this line as bellow it start working

document.write('<script src="localhost/site' + scriptUrl + '"></script>');

Thanks

Link to comment
Share on other sites

What happens if you add "/" in front of "site" in LostKorbakai's code?

document.write('<script src="/site/templates/' + scriptUrl + '"></script>');

This will make the path start from web root. If your PW is in a subfolder, use "/subfolder/site/.....".

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...