I am a newbie, but I have spend the last 2 days reading so may things on this, and the more I read, the more confusing it gets. Not able to find one simple instruction or example to follow, or a simple and complete answer of this very important problem.
I simply want to include a common javascript file using src=. Then when I copy this tree to the server, I do not want to change anything in the code. I do not want to use relative path, since I do not want to edit the HTML file each time I change the tree layout. I want one solution that works when the tree is on the server, and also when it is locally on my PC during development.
I am not looking for something advanced or fancy. But a very simple solution. All what I want is to be able to use a common javascript file between all the HTML files I have in my tree.
The problem is that I do how to load it, since I can't use something like $HOME or ~ or an environment variable and so on, so that the same code works on my home PC, and also when I upload it to my personal web site.
To make it simple to answer this, I show the layout at my PC:
C:/public_html/common_files/common.js
C:/public_html/report/index.htm
On the server, say my site is called www.ABC.com, and I see, when I ftp to it, that there the public_html/ folder where I am supposed to put everything. So on the server, I created the same setup as above
/public_html/common_files/common.js
/public_html/report/index.htm
So far so good. Now the hard part.
How do I load common.js from index.htm file? I do not want to use src=../../common_files/common.js, why? Because I might want to change the layout of the tree, and if I move my report to another level, I do not want to edit it and keep changing the path and counting "../../../../.." etc..
I looked at many things, like ResolverURL but could not figure how to use it.
I tried
<script src="<%=Page.ResolveUrl("~/")%>public_html/common_files/common.js"></script>
But did not work. Remember, this has to work on the PC and on the server.
Here is my current index.htm.
<!DOCTYPE HTML>
<html>
<head>
<script src="../common_files/common.js"></script>
</head>
<body>
my site
</body>
</html>
To explain what I am looking for, assume for the moment that $HOME works in this env., which it does not offcourse, then I could have written
<!DOCTYPE HTML>
<html>
<head>
<script src="{$HOME}/common_files/common.js"></script>
</head>
<body>
my site
</body>
</html>
and this would have worked on the PC and on the server (well, at least it would work on a PC using linux). But the above is just an example of what I am looking for, on windows, I am not sure where $HOME is or how it is used if it is.
question: How to change the above src to load the common.js so that it works both on the PC and on the server but without using relative path?
Please do not give my more links to see, or partial answers, or ask me to download some commercial software to do this or complicated very advanced commands. This problem is so basic and the solution should be simple to follow.
wwwand then copy your site source-tree intowww. You then just need to double-click the exe and it will start serving everything out of thewwwfolder athttp://localhost/. You can't really do what you want to do without a server, so I've given you the simplest server I know of.