admin管理员组文章数量:1332359
I was using an advertising service (banner) which had a simple refresh timer in it. Where I could specify after what time the advert should be reloaded (or a new one should be served)
I've switched my banner provider and the new one does not have that built in option.
I've tried refreshing the div normally but that doesn't work since the content seems to remain the same.
Any ideas on a javascript code which can refresh a banner ad?
<script langauge="javascript">
window.setInterval("refreshDiv()", 60000);
function refreshDiv(){
document.getElementById("advert_div").innerHTML;
}
</script>
and here is the advertisers div
<div id="advert_div">
<script type="text/javascript">
//<![CDATA[
LSM_Slot({
adkey: '645451',
ad_size: '300x250',
slot: 'slot656464'
});
//]]>
</script>
</div>
I was using an advertising service (banner) which had a simple refresh timer in it. Where I could specify after what time the advert should be reloaded (or a new one should be served)
I've switched my banner provider and the new one does not have that built in option.
I've tried refreshing the div normally but that doesn't work since the content seems to remain the same.
Any ideas on a javascript code which can refresh a banner ad?
<script langauge="javascript">
window.setInterval("refreshDiv()", 60000);
function refreshDiv(){
document.getElementById("advert_div").innerHTML;
}
</script>
and here is the advertisers div
<div id="advert_div">
<script type="text/javascript">
//<![CDATA[
LSM_Slot({
adkey: '645451',
ad_size: '300x250',
slot: 'slot656464'
});
//]]>
</script>
</div>
Share
Improve this question
edited Jun 5, 2013 at 15:41
Fahim Akhter
asked Jun 5, 2013 at 14:55
Fahim AkhterFahim Akhter
1,6255 gold badges31 silver badges50 bronze badges
3
- Did you try with setInterval function that call "refreshBanner" function?And are you sure that you banner doesn't change inly when a user click on? @FahimAkhter – SamDroid Commented Jun 5, 2013 at 14:58
- 2 Could you provide code you expected to work? – ElmoVanKielmo Commented Jun 5, 2013 at 14:59
- Forgot to add the code. Added now – Fahim Akhter Commented Jun 5, 2013 at 15:21
1 Answer
Reset to default 3I say my idea or suggest.
I had one situation but there was the script with document.write()
and this is not that you used.
Info: my answer (I was writing before the update's question)
2. idea In your case
<script language="javascript">
window.setInterval("refreshDiv()", 60000);
function refreshDiv(){
document.getElementById("advert_div").innerHTML;
}
</script>
The document.getElementById("advert_div").innerHTML
miss =
as what?
Example
document.getElementById("advert_div").innerHTML="<p>Wele</p>"
EDIT:
You can create the element with
document.getElementById("advert_div").innerHTML="";
var src1 = 'script',
script1 = document.createElement('SCRIPT');
script1.type="text/javascript";
script1.src = src1;
document.getElementById("advert_div").appendChild(script1);
This is a banal example but you can create the function in every banner and create the function:
"use strict";
var name = "foo";
var func = new Function(
"return function " + name + "(){ alert('sweet!')}"
)();
//call it, to test it
func();
Info:
function refreshDiv(){
document.getElementById("advert_div").innerHTML="";
//Calling the function using the if
}
Now I do not know exactly what you want to do and I writing my ideas. Good luck and if you seek help.
本文标签: adsHow to refresh div in javascriptwhich has another script as bodyStack Overflow
版权声明:本文标题:ads - How to refresh div in javascript, which has another script as body? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742314669a2451575.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论