js 文件引用传递参数

每天学习一点点 编程PDF电子书免费下载: http://www.shitanlife.com/code

 

(function() {
var hm = document.createElement("script");
hm.setAttribute("src", "/manager/js/sta-tw.js");
hm.setAttribute("id", "staScript");
hm.setAttribute("appid", appId);
hm.setAttribute("userid", userId);
var s = document.getElementsByTagName("script")[0]; 
s.parentNode.insertBefore(hm, s);
})();
</script>

<!-- <script id="staScript" type="text/javascript" src="/manager/js/sta-tw.js" userid="" appid="3"></script> -->

==============================================================================================


var appId = document.getElementById('staScript').getAttribute('appid');
var userId = document.getElementById('staScript').getAttribute('userid');

alert(appId)

 

 

每天学习一点点 编程PDF电子书免费下载: http://www.shitanlife.com/code

posted @ 2018-03-28 15:40  漫步CODE人生  阅读(2799)  评论(0编辑  收藏  举报