"Chrome detected unusual code" error in previously working iframe

Viewed 3724

I had a perfectly working PHP page with an iframe inside. Suddenly it stoped working in Chrome with this error:

Chrome detected unusual code on this page and blocked it to protect your personal information...

Any idea how to solve it?

3 Answers

The other posts here offer an answer. But none of them offer any code-sample-based explanation, so, I will try :

This is caused by a webpage displaying HTML that was POST'd to it, when that HTML contains JS event triggers, for example :

<p class="someParagraph" onClick="doTheMagicThing();">

If you have an iframe, that receives text like this in a POST or a forum, and you display that text, as well, then Chrome will issue the error (and effectively block the page), unless you have the X-XSS-Protection header disabled.

Naturally, passing huge swathes of html like this between independent components is not considered good design.

Related