0

Hi I am currently working on porting over an application to a new server and I each time I move the application to a new directory I have to manually go in and change all of the img, src, and script tags within the html pages. This is becoming very tedious because there are over 30 different pages.

Is the anyway to create a configuration file that holds global variables that can then be included at the top of every HTML file? For example, if I change the path to a script, the only change I would have to make is in the configuration file and not every separate html file.

edit to clarify:

Currently I have hard coded scipt/img/scr tags that look like this:

<link rel="stylesheet" type="text/css" href="/app/returning/html/returning.css" />

I was hoping I could make the href value a variable in a separate file that can be included at the top of every page and it would look something like this:

<link rel="stylesheet" type="text/css" href="(variable from configuration file here)" /> 
Dan
  • 11
  • 2
  • What kind of variables specifically? Just JS? –  Mar 28 '16 at 20:31
  • Keep them in separate folders, but have all of them in one "global" folder. That folder should probably have the name of your project. – RaminS Mar 28 '16 at 20:31
  • 1
    The easiest thing to do is have one .js file that holds all those variables. Just make sure it's the first thing loaded on every page. However - if these variables are every changing and need to be shared, you're going to need a database solution. – durbnpoisn Mar 28 '16 at 20:32
  • 1
    See [Persist javascript variables across pages](http://stackoverflow.com/questions/1981673/persist-javascript-variables-across-pages) , [Sharing a variable between multiple html pages](http://stackoverflow.com/questions/16264253/sharing-a-variable-between-multiple-html-pages) – Shady Alset Mar 28 '16 at 20:35
  • why is this tagged javascript? Look up how to do relative URL's, there's really no reason I can see to have this application structured like this. http://www.webreference.com/html/tutorial2/3.html It would be a simple enough thing to write JS to do this but it wouldn't work on browsers with js turned off (rare I know). If for some reason you can't use relative URL's use PHP to do it, very simple. – Rick Calder Mar 28 '16 at 20:47
  • Title, at time of writing this comment is "How to create global variables to share between HTML pages". But question really seems to be "How to parameterize resource URLs?" @RickCalder suggests relative URLs, but you're already using relative URLs, yet you seem to have a reason to change those between "new directories". Can you show one example of how shown URL changes? Also - do you use any server-side code to generate the HTML or those are static pages? – G. Stoynev Mar 29 '16 at 03:41

1 Answers1

0

You can create another javascript file with an object with all settings/configurations, and include it in every HTML page.

Something like:

var settings = {
   applicationName : "TEST",
   IsInDebug : true
};
TheDude
  • 3,796
  • 2
  • 28
  • 51
Alexandru Chichinete
  • 1,166
  • 12
  • 23