Load adverts

Load adverts

Hello,

I need to load adverts on each page. Thus, I enumerate all containers with the ads class and write and execute (in order to write the advert in the good container). (ajaxEnabled is true)

Here's my html :

  1. <div data-role="page" data-theme="a" id="asm-home">

        <div id="asm-homeheader" data-role="header">
              <div class="ads" data-ads="top"></div>
        </div>
          
          [...]

    </div>







Thus, for the first loaded page, everything works.
But, when I change page, the javascript  code displays the ads in a white page.

Here's the relative javascript code for ads :


  1.   $('#asm-home').live('pageshow',function(event){
       
        $('div.ads:visible').each(function(m,t) {
        
          var include = '<script type="text/javascript" src="[ads_url]"></' + 'script>';
         
          $(t)[0].innerHTML = '<script type=\'text/javascript\'>' + eval('document.write(include);') + '</script>';
        });
      });











Could you help me ?