We'll, after many months of trying then giving up, I finally found a solution to show adsense ads when theirs a page loaded dynamically.
First, I want to give credit where credit is due. I found the following link last night, which got me started in the right direction:
Here is the js file i'm using:
- $(window).load(function(){
- var ads_top = $("#adsense_top").find("iframe");
-
- //This is where the ads will show when the page is first loaded
- $(ads_top).appendTo("#google_ads_top div");
-
- $("#adsense_top").remove();
-
- $('div').live('pagehide',function(event, ui){
- //This is where the ads will show when theirs a page transition
- $(ads_top).appendTo("#google_ads_top div");
- });
- });
Here is a basic layout of the page. I stripped everything else out. The google adsense code should be inserted at the bottom.
- <!DOCTYPE html>
- <html>
- <head>
- </head>
-
- <body>
- <div data-role="page" data-theme="d">
- <div id="header">
- </div>
-
- <div data-role="navbar">
- </div>
-
- <div id="google_ads_top">
- <div align="center">
- </div>
- </div>
-
- <div data-role="content">
-
- </div>
-
- <div id="footer">
- </div>
- </div>
- <div id="adsense_top" style="display:none;">
- <!--Insert adsense Code-->
- </div>
- </body>
- </html>