Unable to access contents of a safeframe returned

2019-07-24 21:30发布

问题:

  1. I work in adtech company and have a problem when i try and access an safeframe returned by google adx

  2. I need to get a href or img inside the safeframe to check if ad is coming or not as if to find if anything is coming or no ad is being sent.

  3. When i try and access the contents of the safeframe I get error:-

Uncaught DOMException: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "http://www.somerandomname.com" from accessing a cross-origin frame.

What should i do in this case as finding out if no ad or ad is returning is important in business sense.

回答1:

That's not possible, because of iframe content is on different domain.

But DFP is smart enought. When you have ADX intergrated in your DFP, you can create conditions, that will prioritise ADX ads here:

More about it here: https://support.google.com/adxseller/answer/6300696?hl=en https://support.google.com/adxseller/topic/3376095?hl=en&ref_topic=2911899