Multiple OnReady Events Writing Code to Wrong DIV Tags When Back Button is Click

Multiple OnReady Events Writing Code to Wrong DIV Tags When Back Button is Click

Hi,

I have a series of ASP.Net sites that use jQuery in UserControls to write banner ads to pages post DOM load. It works great when landing on a page for the first time or when navigating to a page using a link. Unfortunately when going back to a page using the back button in a Firefox browser it will write content to the wrong div tags all of which are unique.

My code is either for writing script tags, iframes, or images wrapped in a hyperlink. I also use the lazyloadads plugin for Bidvertiser ads, but not for anything else because it won't render multiple div tags in IE. With the exception of the plugin my code usually looks as follows:

<script language="javascript" type="text/javascript">
        jQuery(document).ready(function ($) {
            var script = document.createElement('script');
            script.setAttribute("type", "text/javascript");
            script.setAttribute("src", "http://cdn.wibiya.com/Toolbars/dir_0578/Toolbar_57860/Loader_578607.js");
            var area = document.getElementById("wibiyatb");
            $(area).html(script);
        });   
    </script>

OR I have the following in a .ascx file:

<div id="zjuicyads">
</div>
<script language="javascript" type="text/javascript" src="http://stdcarriers.com/js/topad.js">
</script>

Followed by the following in a .js file:

jQuery(document).ready(function ($) {
    var myjbanner = '<iframe border="0" frameborder="0" marginheight="0" marginwidth="0" width="736" height="98" scrolling="no" allowtransparency="true" src="http://adserver.juicyads.com/adshow.php?adzone=54200"></iframe>';
    var jarea = document.getElementById("zjuicyads");
    $(jarea).html(myjbanner);
}); 

That code has worked fine for the most part so far, but in some cases (ex: Bidvertiser) adding a script like that always made the page load before being replaced by a white screen.

A good example can be found at Celebrities with STDs where clicking on a profile will load a profile just fine, but hitting the back button will take you back to the celeb list with ads loading in the wrong places.

I'm for a quick fix to this because I don't have time for anything else. When responding consider the fact that I am not a front end developer, rarely look beyond the AJAX Control Toolkit for UI construction, and have no interest in jQuery beyond making ads load faster.