Forum Moderators: open

Message Too Old, No Replies

Moving Ad Code to Bottom of Page and Loading into Another DIV

         

pubdougx

1:37 pm on Oct 2, 2010 (gmt 0)

10+ Year Member



Having a problem with some CSS / Javascript coding for loading content into an earlier div container in the page that I'm hoping someone has an answer for. What follows works perfectly in IE, but not in Firefox for some reason.

The page code layout looks something like this:

[ miscellaneous content]

<div id="firstbx"></div>

[ miscellaneous content]

<div id="secondbx"></div>

[ miscellaneous content]


Now, at the very bottom of the page (just before the closing body tag) I have:

<div id="firstbxloader" style="display:block;"> [ GOOGLE ADSENSE CODE] </div>

<div id="secondbxloader" style="display:block;"> [ OTHER BANNER NETWORK CODE ] </div>

<script type="text/javascript">
var firstbxload = document.getElementById('firstbxloader');
document.getElementById("firstbx").appendChild(firstbxload);
</script>

<script type="text/javascript">
var secondbxload = document.getElementById('secondbxloader');
document.getElementById("secondbx").appendChild(secondbxload);
</script>


Using IE, this works perfectly. The contents of the firstbxloader DIV ID gets loaded into the firstbx DIV ID and the contents of the secondbxloader gets loaded into the secondbx DIV ID. You can reload the page over and over and there's no problem.

However, with Firefox, it's not working consistently. On the first loading of a page everything is fine, but if you reload the page the div content placement can get swapped out. ie. On a reload in firefox the secondbxloader content is getting placed in the firstbx div.

MartinWeb

4:00 am on Nov 14, 2010 (gmt 0)

10+ Year Member



Hmm..... I'm not sure about this, but possibly the js is running before the page is fully loaded.

You might want to put the javascript into a function, and then use <body onload="functionNameHere()"> to make sure the page loads first