html - Relative Paths in Javascript in an external file -
So I'm running this JavaScript, and everything works well, except for the background image path. It works on my local ASP.NET dev environment, but when it is deployed on a server in the virtual directory it does not work.
This is in an external .js file, the folder structure is
site / content / style.css site / scripts / myjsfile.js site / images / filter_xpants.jpg Site / Images / Fields_Grage. JPG
Then this is where the JS file is included.
site / view / product list / index.aspx $ ("# toggle") . Click (function () {if (left.width ()> gt; 0} {AnimateNav (left, right, 0); $ (this). CSS ("background", "url ('../ images / filter_expant .jpg ') "} other {animatane (left, right, 170); $ (this). CSS (" background "," url (' ../ images / filter_ collapse.jpg ') ");}}) ; I have tried to use '/ images / filters_collapse.jpg'
and that does not work; However, if I '../../image/filt_ collapse.jpg'
. , then I seem to be working on the server. Basically, I should have the same functionallity as ASP.NET tilda - ~
.
Updates
Are they contained in the paths in external .js files relative to the page, or the actual location of the .js file?
javascript file path
when in the script, paths were displayed Pages are relative to
To make things easier, you can print a simple JS announcement like this and use this variable in all your scripts: / P> < P> solution, which was working on stack overflow around February 2010:
If you were going around this page on 2010, then you can take a look at the Stack Overflow html source , you will see this faulty one- Liner [formatted 3 lines] can be found in :)] & lt; Head / & gt;
section
Comments
Post a Comment