So I have written this JS for a custom site. I have created a "global" file in PHP that defines all the variables for the site and inputs them into all the pages that call for the those variables defined in "global". For example if you wanted to change the title of the site, you would go to the "global" PHP file and change the variable defined as title. This would change the title on every page of the site.
Here's The Question
Is there any way to define the JS variable $address (Red Below) in the "global" file I already have? (PHP file). Any solutions other than that? This way I do not have to go in and change every page by hand.
Thank You in advance for your time.
Alan.
<code>/* Google Maps
/* ---------------------------------------------------------------------- */
// Needed variables
var $map = $('#map'),
$tabContactClass = ('tab-contact'),
$address = '123 street roseville ca 95678';
As long as your global file writes the code to the browser, variables in the global file will function just fine.
e.g., My site runs classic ASP and my JS file is actually a .asp file because I customize the JS based on a few things. So the reference to my JS file looks something like:
My site also uses global files for stuff like global variable settings, navigation functions, etc.
(e.g., "var ImagesDir", "Function Left-Nav", etc.). This file is included at the top of every page. If I update this page so that it writes javascript to the browser, this javascript is honored on every page.
e.g.,
Code:
<%
'blah blah - some ASP code here
%>
<script type="text/javascript">
var someGlobalVariable = 'someValue';
</script>
<%
'some more ASP code here if I want it
%>
With the above, I can reference the javascript variable "someGlobalVariable" on any of my pages.
Bookmarks