2

I want to load JS code from external site when user click on button. For example:

 <button onclick="LoadJSFromURL('facebook.com/blablabla')" />

and when user press button we attach new script to the document:

<script> Share.WorkUrl="http://MySite.com"; Share.UserId=5 </script> <script src="http://Facebookcom/blabalbal" ></script>

and then we must execute this script. Is it real?

Neir0
  • 12,849
  • 28
  • 83
  • 139

1 Answers1

3

check this : How do you dynamically load a javascript file from different domain?

var script = new Element("script", {src: "myBigCodeLibrary.js", type: "text/javascript"});

script.onload = script.onreadystatechange = function(){
    if (!this.readyState ||
        this.readyState == "loaded" || this.readyState == "complete") {
        //script is loaded
    }
};
Community
  • 1
  • 1
Pranay Rana
  • 175,020
  • 35
  • 237
  • 263