How to add JavaScript link dynamically?

Posted by Allemahesh under JavaScript on 1/6/2014 | Points: 10 | Views : 1571 | Status : [Member] [MVP] | Replies : 1
I am using Mapquest Api in my web application. I am using this Mapquest Api in different pages. This api is given below:-

<script src=""></script>

My question is How I can make key=YOURKEY dynamic. I mean to say that how to pass YOURKEY dynamical.

I have thought web.config file but I am not able to do this.
Can any one help me to sort this?


Posted by: kgovindarao523-21772 on: 1/6/2014 [Member] [MVP] Bronze | Points: 25

take a script tag like this.
<script type="text/javascript" id="myScript"></script>
Now in another script tag
define variable like
var src = "";

and your dynamic varible is YOURKEY (may be passed it by click function)
and then dynamically assign src attibute to myScript

Thank you,

Allemahesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response