代码改变世界

js 文件引用传递参数

2017-08-17 11:15  xiangjune  阅读(904)  评论(0编辑  收藏  举报


(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)