Forum Moderators: open
I need to refresh a div which contains an ad while the rest of the page stays the same. I think I'm pretty close by reading the previous posts on this site, but one odd thing is tripping me up and I can't figure out why. When I call my function to refresh the div, it replaces everything on the page instead of just swapping out the div. I'd appreciate any help from you js experts!
<script type="text/javascript">
function adBump(rand){
//setup ad call. returns a doc.write command from ad server
var adcall = "http://www.example.com?"+rand+"other_paramters";//adds the advertisement graphic above the ad when it loads.
document.getElementById("adLabel").innerHTML = "<img src='http://www.example.com/images/adv_180x9.gif' width='180' height='9' alt='Advertisement'>";
//selects ad div, empties it then appends the new js call.
var b = document.getElementById("ad");
b.innerHTML = "";
var js = document.createElement("script");
js.type = "text/javascript";
js.src = adcall;
b.appendChild(js);
}
</script>
<div id="adArea">
<div id="adLabel">Ad label goes here</div>
<div id="ad">Ad goes here</div>
</div>
[edited by: DrDoc at 7:27 am (utc) on July 28, 2007]
[edit reason] Examplified URLs [/edit]
[developer.mozilla.org...]
[w3schools.com...]
[sitepoint.com...]
[edited by: DrDoc at 7:28 am (utc) on July 28, 2007]
[edit reason] Examplified URLs [/edit]