Есть такое решение. Но оно не всегда работает.
Ищи в сторону
PHP код:
window.onbeforeunload = function()
Либо можно полностью запретить скрипты в ифрейме.
http://htmlbook.ru/html/iframe/sandbox
With HTML5 the iframe sandbox attribute was added. At the time of writing this works only on Chrome and Safari but does pretty much what you want:
<iframe src="url" sandbox="allow-forms allow-scripts"></iframe>
If you want to allow top-level redirects specify sandbox="allow-top-navigation".