IE9: Weird Javascript error

2019-02-15 23:40发布

问题:

I am getting an error while trying to display Google DFP ad banners in my website. The ads are showing in all browsers except IE9. You can view a simple test page with the banner here: (demo taken offline). The error is "Exception thrown and not caught" (google_ads.js, line 34 char 474).

I can view the ad in IE9 if I switch to IE7/8 compatibility view, so the problem appears to be with IE9. I am not sure if this is restricted to my computer, or if this is a universal problem. If it's the latter, this is a very serious concern for anybody running Google ads!

Your ads might not be showing on any of the newer computers with IE9 installed!

Can somebody please have a look, and confirm if this is a Google issue, or an issue with the my code?

Wild Thing

回答1:

I couldn't really find a permanent solution, but if anybody runs across this problem, you can just add

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /> 

in your header to force your browser to emulate the IE8 document mode. This seems to fix the JS errors as well.