Texan78 Posted May 9, 2013 Share Posted May 9, 2013 I have a script for a Google Map which works great. I have the code to the map in a seperate Js file which I call in the page where I want to display like this. <script src="https://maps.googleapis.com/maps/api/js?key=(GKey)&sensor=false"></script> <script type="text/javascript" src="gmap/util.js"></script> <script type="text/javascript" src="gmap/killerTornados.js"></script> the killerTornados.js is the file that contains the code for the map. Now I have made a var in the top of the file for settings. Which is called var GKey. That way when I share this script uses can set all their settings there. My question is how do I define the variable in the script include? In the URL below I have tried to define the var (GKey) like you do in the actual script but this does work this way like this. How do I properly define this? <script src="https://maps.googleapis.com/maps/api/js?key=(GKey)&sensor=false"></script> -Thanks Link to comment https://forums.phpfreaks.com/topic/277817-setting-variable-in-url/ Share on other sites More sharing options...
requinix Posted May 9, 2013 Share Posted May 9, 2013 You have to write out an entire <script type="text/javascript"> document.write("<scr" + "ipt type='text/javascript' src='https://maps.googleapis.com/maps/api/js?key=" + GKey + "&sensor=false'><" + "/script>"); </script> <script type="text/javascript" src="gmap/util.js"></script> <script type="text/javascript" src="gmap/killerTornados.js"></script> Link to comment https://forums.phpfreaks.com/topic/277817-setting-variable-in-url/#findComment-1429218 Share on other sites More sharing options...
Texan78 Posted May 9, 2013 Author Share Posted May 9, 2013 Thank you, I tried that but apparently Google doesn't like that so I will just have to keep it like it is. Thanks for your help. Link to comment https://forums.phpfreaks.com/topic/277817-setting-variable-in-url/#findComment-1429239 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.