# DIV tag replaces entire page when refreshed

**URL:** https://forum.kirupa.com/t/div-tag-replaces-entire-page-when-refreshed/233790
**Category:** web dev
**Created:** [July 26, 2007, 10:14pm UTC](https://forum.kirupa.com/t/div-tag-replaces-entire-page-when-refreshed/233790 "2007-07-26T22:14:58Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![MDiddy](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@MDiddy](https://forum.kirupa.com/u/MDiddy)
#### Post date: [July 26, 2007, 10:14pm UTC](https://forum.kirupa.com/t/div-tag-replaces-entire-page-when-refreshed/233790/1 "2007-07-26T22:14:58Z")

</div>

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!

```auto

<script type="text/javascript">
function adBump(rand){
//setup ad call. returns a document.write() command from ad server
var adcall = "http://oas.#*$!x.com/RealMedia/ads/adstream_jx.ads/www.#*$!x.com/#*$!x/"+rand+"other_paramters";

//adds the advertisement graphic above the ad when it loads.
document.getElementById("adLabel").innerHTML = "<img src='http://images.#*$!x.com/images/#*$!xx/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>

```
