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.