开发者

Loading Ajax Response Data with Adsense Codes inside

开发者 https://www.devze.com 2023-03-20 18:58 出处:网络
I\'m 10000000% sure that this question has been asked before, however, the majority of the responses that I came across were from back in 2005, 2006 and so on. Not to mention, almost all of the questi

I'm 10000000% sure that this question has been asked before, however, the majority of the responses that I came across were from back in 2005, 2006 and so on. Not to mention, almost all of the questions themselves were too general. Therefore, I'm asking this so that for anyone else needs to find this out, then they won't need to dig through about 50 webpages to get an idea.

My question is simply that I have a webpage that has Google Ads embedded into the HTML of the website. The website was first developed as a static HTML site where each link reloaded a new page. Nevermind the backend technology of the website - the website itself produces purely dynamic content. The website is close to completion and now a fully-ajax listener has been added to all the links. When any of the links are clicked, JavaScript takes over, parses the link and sets that using popstate or the hashbang. The page itself is then queried to the server via AJAX and the content is updated using document.getElementByID('container').innerHTML=ajax.responseText; This way, there is almost a 100% method of accessing content that was replaced by AJAX.

This all works fine, but the responseText itself may, WILL contain Google Ads, and I was just wondering how to 开发者_如何学Cdisplay them as if it were a static page. Clearly this doesn't work. Here are the options that I've come across:

  1. Use an IFrame: An IFrame seems to be an effective way to load the content; just stick the adsense codes a simple adsense.html iframe file and let the browser and


directly into page, it isn't possible

  • it's against their TOS
  • there is document.write() omitted in ajax request

Your chance is: Create simple iframe

<iframe src="advert.html"></iframe>

and in advert.html, add your advert code

It's then loaded fine without problems.

Good luck

0

精彩评论

暂无评论...
验证码 换一张
取 消