Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to redirect page inside iframe to another one but we must stay in iframe

Could anyone help me? Is it possible to code this? Redirect page inside iframe to another one but we must stay in iframe . Without influence to parent site. I tried many scripts but nothing worked. Here is main code which i use. width and height is only for testing. I use HTML5 sandbox to prevent iframe breaks to main site. I need that to hide referer. Now parent site is showed as referer in iframed site, but i want to first site in iframe was used as referer to redirected one. Maybe it is crap, but i need that.

<!DOCTYPE html>
<html>
<body>


<iframe  width="1025" height="350" sandbox="allow-same-origin allow-scripts allow-popups allow-forms" src="URL"; </iframe>

</body>
</html>
like image 415
Lubos Baan Avatar asked Jan 26 '15 22:01

Lubos Baan


People also ask

Can you redirect inside an iframe?

Redirect the page containing your iframe embed Modern browsers will prevent an iframe from changing the location of its parent page for security reasons. Your iframe embed code and JavaScript code will need to be modified to allow this behavior.

How do I stop redirecting iframe?

How do I stop redirecting iframe? You can set sandbox=”” , which prevents the iframe from redirecting.

What is redirect using iframe?

About. Hidden redirect allows you to quickly create subdomains that seamlessly redirect users to another URL - without changing the URL shown in the address bar. This is done using an iFrame redirect (full-screen iFrame).


2 Answers

If you want the script to run from the frame:

document.location.href = "http://...";

If you want the parent page to redirect (change) the frame location:

HTML:

<iframe name="myFrame" ... />

JavaScript:

window.frames["myFrame"].location = "http://..."
like image 148
pyb Avatar answered Oct 06 '22 02:10

pyb


$(function() {
    if ('app' !== $('body').attr('id')){
        window.setTimeout(function(){
            window.top.location.href = 'your redirect url'; 
        }, 5000);
    }
});

in IFRAME use

sandbox="allow-top-navigation allow-scripts allow-forms"
like image 24
Iury Martins Avatar answered Oct 06 '22 02:10

Iury Martins