Google Adsense inside a jquery dialog?

2019-07-20 14:31发布

问题:

I have a website that opens a dialog using jquery

function showDialogUser(url, options){
    if (!$('#myDialogUser').dialog('isOpen')) {
    $("#mydialogUser").dialog("close");
}
   options = options || {};
   var tag = $('#myDialogUser');
 //This tag will the hold the dialog content.
   $.ajax({
     url: url,
     type: (options.type || 'GET'),
     beforeSend: options.beforeSend,
     error: options.error,
     complete: options.complete,
     success: function(data, textStatus, jqXHR) {
       if(typeof data == "object" && data.html) { //response is assumed to be JSON
         tag.html(data.html).dialog({modal: options.modal, title: data.title, height: 550, width: 1000}).dialog('open');
       } else { //response is assumed to be HTML
    var matches = data.match(/<title>(.*?)<\/title>/);
        var spUrlTitle = matches[1];
         tag.html(data).dialog({modal: true, title: spUrlTitle, height: 560, width: 1000}).dialog('open');
       }
       $.isFunction(options.success) && (options.success)(data, textStatus, jqXHR);
     }
   });
}

It loads another page.asp file that contains a google adsense code.

The problem is that it is not displaying the ad.

When I try to access the page.asp on my browser the ad appear.

How can I do it ? I tried several ways but it didn't work

Thanks

回答1:

Google adsense won't work properly inside of a jQuery UI Dialog because it would require moving the adsense html, which could in turn generate invalid impressions, risking your account being closed.

I suggest against it.