网友的相关建议:
function CSS(href, id) { var css = document.createElement("link"); css.rel = "stylesheet"; css.type = "text/css"; css.href = href; id && (css.id = id); document.head.appendChild(css);} /** * 动态引入javascript文件, * Usage: * function script_onload() { * alert(1); * } * var load_js = new Script(script_onload); * load_js.set("http://static.gongju.com/js/jquery-1.4.4.min.js"); * @param id: domid [optional] * @param callback js文件加载完了callback function */function Script(callback) { var js = document.createElement("script"); this.js = js; js.type = "text/javascript"; document.body.appendChild(js); Script.prototype.set = function(url, id) { this.js.src = url; id && (this.js.id = id); }; if (callback) { if (navigator.appName.toLowerCase().indexOf('netscape') === -1) { js.onreadystatechange = function() { js.readyState === 'complete' && callback(this); } } else { js.onload = function() { callback(this); } } }}/** * 加载阿里云sdk * https://help.aliyun.com/document_detail/51991.html?spm=a2c4g.11186623.6.708.7cJyna */var load_vodsdk = function(fn) { if (typeof Aliplayer==="function") { fn.apply(this, arguments); } else { CSS("https://g.alicdn.com/de/prismplayer/2.3.5/skins/default/aliplayer-min.css"); var script = new Script(function() { fn.apply(this, arguments); }); script.set("https://g.alicdn.com/de/prismplayer/2.4.0/aliplayer-min.js"); }}; load_vodsdk(function() { var player = Aliplayer({ id: "my-video", autoplay: true, width: "750px", height: "430px", vid : vid, playauth : playauth, cover: cover, language: 'en-us' }); });