How to redirect a page inside an iframe to another, but we must stay in the iframe

Can anyone help me? Can this be encoded? Redirect the page inside the iframe to another, but we must stay in the iframe. No effect on the parent site. I tried a lot of scripts but nothing worked. Here is the main code that I use. width and height are for testing only. I use the HTML5 sandbox to prevent iframes from going to the main site. I need to hide the referee. Now the parent site is displayed as the referent on the iframed site, but I want the first site in the iframe to be used as the referent for redirection. It may be shit, but I need it.

<!DOCTYPE html> <html> <body> <iframe width="1025" height="350" sandbox="allow-same-origin allow-scripts allow-popups allow-forms" src="URL"; </iframe> </body> </html> 
+7
javascript redirect iframe
source share
1 answer

If you want the script to be executed from a frame:

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

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

HTML:

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

JavaScript:

 window.frames["myFrame"].location = "http://..." 
+8
source share

All Articles