Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2014
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. (function(doc, script) {
  2. var js,
  3. fjs = doc.getElementsByTagName(script)[0],
  4. add = function(url, id, cb) {
  5. if (doc.getElementById(id)) {return;}
  6. js = doc.createElement(script);
  7. js.src = url;
  8. id && (js.id = id);
  9. fjs.parentNode.insertBefore(js, fjs);
  10.  
  11. //- bind the callback on onload an onreadystatechang
  12. js.onload = js.onreadystatechange = cb;
  13. };
  14.  
  15. add('//example.com/js/remote.js', function(){
  16. //- do some post-load initialization.
  17. console.log('remote loaded and onload fired'); // for debug purposes.
  18.  
  19. // the remote script gives us an object
  20. var options = {'array': 'of','parameters':'and values'},
  21. myObj = new remoteObject(options);
  22.  
  23. myObj.init();
  24.  
  25. });
  26. }(document, 'script'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement