Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function(doc, script) {
- var js,
- fjs = doc.getElementsByTagName(script)[0],
- add = function(url, id, cb) {
- if (doc.getElementById(id)) {return;}
- js = doc.createElement(script);
- js.src = url;
- id && (js.id = id);
- fjs.parentNode.insertBefore(js, fjs);
- //- bind the callback on onload an onreadystatechang
- js.onload = js.onreadystatechange = cb;
- };
- add('//example.com/js/remote.js', function(){
- //- do some post-load initialization.
- console.log('remote loaded and onload fired'); // for debug purposes.
- // the remote script gives us an object
- var options = {'array': 'of','parameters':'and values'},
- myObj = new remoteObject(options);
- myObj.init();
- });
- }(document, 'script'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement