早上好!
我希望这个平台上的人能解释一下跟随JS的逐行工作
<script>
/*<![CDATA[*/
(function(w, a, b, d, s) {
w[a] = w[a] || {};
w[a][b] = w[a][b] || {
q: [],
track: function(r, e, t) {
this.q.push({
r: r,
e: e,
t: t || +new Date
});
}
};
var e = d.createElement(s);
var f = d.getElementsByTagName(s)[0];
e.async = 1;
e.src = '//flintnet.actonservice.com/cdnr/94/acton/bn/tracker/17118';
f.parentNode.insertBefore(e, f);
})(window, 'ActOn', 'Beacon', document, 'script');
ActOn.Beacon.track(); /*]]>*/
</script>
我对 JS 有很好的应用知识,但我无法完全理解它!谢谢!
最佳答案
本质上是这样
window.ActOn = window.Acton || {}; // create ActOn global if it doesn't exist
window.Acton.Beacon = window.Acton.Beacon || { // create Beacon object on ActOn if it doesn't exist
q: [], // an empty array
track: function(r, e, t) { // function to push {r: arg1, e: arg2, t: arg3 || now} onto q
this.q.push({
r: r,
e: e,
t: t || +new Date
});
}
};
var e = document.createElement('script'); // create a script element
var f = document.getElementsByTagName('script')[0]; // find the first script in the document
e.async = 1; // set async = "1" on the new script element
e.src = '//flintnet.actonservice.com/cdnr/94/acton/bn/tracker/17118'; // set the source of the script element
f.parentNode.insertBefore(e, f); // insert the script as the top most script on the page - this will fail on a page with no scripts
ActOn.Beacon.track(); // add a "track" to beacon.q = { r: undefined, e: undefined, t: now }
关于javascript - 理解一个 javascript 代码片段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32344364/