problem to display dynamically a javascript google ad in an iframe using jquery

前端 未结 2 1678
暗喜
暗喜 2021-01-26 07:31

We try to display the google ad in an iframe that we add dynamically. In an iframe, the field \"src\" is generally an url, but we want to use the data:text/html format to be abl

2条回答
  •  长情又很酷
    2021-01-26 07:49

    In Chrome's intent to keep hackers and virus creators at bay, they do not allow access to an iframe using javascript when it is communicating with a different domain then the site it is hosted on.

    You are going to be stuck in this method and I am unsure that there is a workaround. Either way, Google ads should be placed directly into the website as it uses the content to generate relevant advertisements to be displayed on the page. If you are looking for a way to display your own advertisements, it should either be done dynamically, written in the code language of choice, or using the ad creator on adsense.google.com to display your own ads instead of public service ads.

    I personally feel that it would be much more simple that way.

提交回复
热议问题