Arjun Arjun - 3 months ago 23
Javascript Question

Javascript errors from Google Adsense

On several of my adsense running sites, I have been getting the following errors:

Unable to post message to [http://]
Recipient has origin

Unsafe JavaScript attempt to access
frame with URL
[http://] from frame
with URL
Domains, protocols and ports must match.

(from the Chrome javascript console)

The ads seem to show properly and it doesn't affect my native javascript code. However sometimes these errors seem to slow down page loading. How can I fix this problem?

(I modified the URLs to let me post this as I'm a new user)


Google have messed up their script. There's not much you can do about it.

For some reason, included in the parent page by the AdSense scripts, is trying to send information about the advert into a newly-written <iframe> created to hold the advert, using the new HTML5 postMessage facility:

            ha(this, function (f, e) {

Yeah. Some nice minified/obfuscated code there. Trust me, Pa is 'postMessage'!

The targetOrigin argument in this call, is set to However, the new iframe was written with its src set to about:blank. This doesn't match the target origin, so the browser must refuse to send the message. Only Chrome seems to be dropping an actual whinge to the console log about it though.

No idea why it's doing this at all, never mind why it's not just using '*' as a target origin... I'm not really feeling like wading into the obfuscated script to find out. However, this error should not cause page loading to slow down. If you're seeing pauses it's usually resolving and fetching other external scripts.