这个引入方式,我也想试试,但是最后面的一部分,_AIHECONG('ini',。)这个函数我怎么找都找不到,源码是加密的,不容易看懂,请问如果我要模仿使用,JS文件里面该如何写,让我这样引入并执行其中的一个方法?我尝试写过一个函数进去,但是感觉无效。无法执行<script>
//网页接入代码
(function (w, d, s, n, a, e) {
w[n] = w[n] || function () {
(w[n].z = w[n].z || []).push(arguments)
};
a = d.createElement(s), e = d.getElementsByTagName(s)[0];
a.async = 1;
a.charset = "UTF-8";
a.src = "https://pubres.aihecong.com/hecong.js";
e.parentNode.insertBefore(a, e)
})(window, document, "script", "_AIHECONG");
//在初始化的时候去除聊天按钮
_AIHECONG('ini',{
entId : '团队ID',
button : false //去除聊天按钮
});
</script>
//网页接入代码
(function (w, d, s, n, a, e) {
w[n] = w[n] || function () {
(w[n].z = w[n].z || []).push(arguments)
};
a = d.createElement(s), e = d.getElementsByTagName(s)[0];
a.async = 1;
a.charset = "UTF-8";
a.src = "https://pubres.aihecong.com/hecong.js";
e.parentNode.insertBefore(a, e)
})(window, document, "script", "_AIHECONG");
//在初始化的时候去除聊天按钮
_AIHECONG('ini',{
entId : '团队ID',
button : false //去除聊天按钮
});
</script>
(function (w, d, s, n, a, e){})(window, document, "script", "_AIHECONG");
即:
w 的值是 window
d 的值是 document
s 的值是 "script"
n 的值是 "_AIHECONG"这样在匿名函数内 w[n] 就等于是 window["_AIHECONG"]w[n] = w[n] || function () {
等于
window["_AIHECONG"] = window["_AIHECONG"] || function () {
_AIHECONG('ini',{
entId : '团队ID',
button : false //去除聊天按钮
});
这个方法,应该是hecong.js里面的一个用于初始化的方法之前那些方法,是用于加载hecong.js这个js加载好了之后就执行这个初始化的方法。这种写法,是很多专业插件比较通用的写法,比如google的站长工具等
alert("JS初始化加载");
}
这样的完全没用啊,他那个还能传参
(function (w, d, s, n, a, e) {// 相对于的实参w = window, d = document, s = "script", n = "_AIHECONG" ,a=e=null
w[n] = w[n] || function () { //w[n]=window["_AIHECONG"],存在就取本身,不存在就会取后面的函数
(w[n].z = w[n].z || []).push(arguments)
};
a = d.createElement(s), e = d.getElementsByTagName(s)[0];//创建一个新的script标签 获取文件的第一个script标签
a.async = 1;
a.charset = "UTF-8";
a.src = "https://pubres.aihecong.com/hecong.js";
e.parentNode.insertBefore(a, e)
})(window, document, "script", "_AIHECONG");
//在初始化的时候去除聊天按钮
_AIHECONG('ini',{
entId : '团队ID',
button : false //去除聊天按钮
});
转换成简单的就是这样 window["_AIHECONG"] = window["_AIHECONG"] || function () {
( window["_AIHECONG"].z = window["_AIHECONG"].z || []).push(arguments)
};
var a= document.createElement("script"), e = document.getElementsByTagName("script")[0];
a.async = 1;
a.charset = "UTF-8";
a.src = "https://pubres.aihecong.com/hecong.js";
e.parentNode.insertBefore(a, e)
//在初始化的时候去除聊天按钮
_AIHECONG('ini',{
entId : '团队ID',
button : false //去除聊天按钮
});