javascript - Parent redirect when using iframe -
i know there several questions/answers how redirect parent window within iframe, 1 has slight twist.
i need able redirect parent window when page in iframe changed. however, page in iframe not on domain, can't use parent.window.location trick suggested in other threads.
so, example, if put stackoverflow.com in iframe, need parent frame redirect when user clicks link on stackoverflow page.
i doubt possible, thought there might sort of polling of iframe parent can or something.
this bit convoluted, should trick. if define iframe this
<iframe id="xmyiframe" src="http://someurl" onload="replaceload(this)" ></iframe>
then can define javascript code;
function replaceload(oiframe) { oiframe.onload = function () { location.href = 'http://www.microsfot.com' } }
on load of initial iframe url inital onload
event handler fires replaces new handler fire after next load i.e. after user clicks link in iframed page.
Comments
Post a Comment