views:

1093

answers:

1

Hey guys,

I am building a Firefox extension and have come a long way. One of the parts of my extension is where I display a DIV at the bottom of the page and I want to put an ad into the div, but for some reason every time it does so, it redirects to another page entirely with the ad on it. So it looks like its not allowing me to insert this code below into the div that sits at the bottom. Any chance anyone can help?

This code of course calls the "ad_display.js" file and thats where it does the redirect. Any way I can do this or am I stuck in the water?

Thanks!!!

    <!-- Beginning of Project Wonderful ad code: -->
<!-- Ad box ID: 38154 -->
<script type="text/javascript">
<!--
var pw_d=document;
pw_d.projectwonderful_adbox_id = "38154";
pw_d.projectwonderful_adbox_type = "2";
pw_d.projectwonderful_foreground_color = "";
pw_d.projectwonderful_background_color = "";
//-->
</script>
<script type="text/javascript" src="http://www.projectwonderful.com/ad_display.js"&gt;&lt;/script&gt;
<!-- End of Project Wonderful ad code. -->
+3  A: 

Two solutions:

  • Either you replicate the functionality of that ad_display script, change "document.write(pw_s)" to something a little saner like "document.getElementById('mydivwithanad').innerHTML=pw_s"
  • Ether you use insert an iframe in the page rather than a div, and you inject that code in the iframe.
Etienne Perot
Ah, document.write explains the disappearing page problem. document.write can only be correctly used /while/ the page is loading, not after.
Matthew Flaschen
Exactly, document.write is really destructive. So basically, either you use a non-destructive method (solution 1), or you use it in a "sandboxed" environment, an iframe (method 2).
Etienne Perot
Thank you, I worked with number 1.
Scott