[英]How do you include adsense javascript inside another javascript code
How do I add adsense code to this javascript code. 如何将adsense代码添加到此javascript代码。 I think there might be a solution with jquery and getscript, but I'm not able to get it to work 我认为jquery和getscript可能有解决方案,但我无法使其正常工作
<script>
var rep = $("#topbar").find(".reputation-score").text().replace(/,|\s/g,'');
if (rep.match(/\d+k/i)) rep = rep.replace(/k/g, '') * 1000;
if (rep == "") rep = 0;
if (rep < 200 && $("#banner-bottom").length == 0) {
if ($(".answer").length == 0)
abovebanner = $("#answers-header");
else
abovebanner = $(".answer:first");
abovebanner.after('HELP ADD ADSENSE CODE HERE');
}
</script>
and guys I'm not very good with javascript, so if you guys could paste a working solution. 和伙计们,我对javascript不太满意,所以如果你们可以粘贴有效的解决方案。 I'd really appreciate it. 我真的很感激。
This page explains a method to do this. 本页说明了执行此操作的方法。 Once you have created the wrapper function (addJavascript) mentioned on that page added, your last line would like something like: 创建添加页面上提到的包装器函数(addJavascript)后,您的最后一行将如下所示:
addJavascript('adsense-library-name.js','head');
The implementation of addJavascript (from the page above): addJavascript的实现(来自上一页):
function addJavascript(jsname,pos) {
var th = document.getElementsByTagName(pos)[0];
var s = document.createElement('script');
s.setAttribute('type','text/javascript');
s.setAttribute('src',jsname);
th.appendChild(s);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.