Jump to content

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>
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.