标签:io strong for ar cti amp ad ef
1、 添加脚本加载的状态事件。
_scriptOnload = doc.createElement(‘script‘).readyState ? function(node, callback) { var oldCallback = node.onreadystatechange; node.onreadystatechange = function() { var rs = node.readyState; if (rs === ‘loaded‘ || rs === ‘complete‘) { node.onreadystatechange = null; oldCallback && oldCallback(); callback.call(this); } }; } : function(node, callback) { node.addEventListener(‘load‘, callback, false); };
2、 为界面添加 加载脚本的Js,
head = doc.getElementsByTagName(‘head‘)[0] || doc.documentElement, _getScript = function(url, fn) { var node = doc.createElement(‘script‘); node.src = url; node.async = true; _scriptOnload(node, function() { fn && fn.call(node, ‘‘); if (head && node.parentNode) { head.removeChild(node); } }); head.insertBefore(node, head.firstChild); return node; }
如何为界面的元素添加事件处理?,布布扣,bubuko.com
标签:io strong for ar cti amp ad ef
原文地址:http://my.oschina.net/frankies/blog/304030