I have an iFrame on my website that is pointing to another domain. When the user finishes filling out a form on the site in the iFrame, the site sends my website a URL. I want to take that URL and force the parent to load that URL. I was using the following code, but it did not work.
<script type='text/javascript'>
if (top !== self) top.location.href = self.location.href;
</script>
Basically, it appears that you are asking how you can detect the new src
of the iframe
after it has redirected.
Had your iframe
page been in the same domain as your own, this would be no problem. You would retrieve it like this:
document.getElementById("ID_OF_YOUR_IFRAME").contentWindow.location.href
But because it's an external domain, browsers will prevent you from do this as a security policy, you're not allowed to access that information.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.