Jump to content

Setting Variable in URL


Texan78

Recommended Posts

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

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.