在web开发中,我们经常会遇见需要动态写入js文件,如何解决呢?
下面提供一种方法,将你要应用的js文件用document.write写出来,举例如下:
<script type="text/javascript">
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "img.easou.com/es.js' type='text/javascript'%3E%3C/script%3E"));
</script>