iframe USES JavaScript to control home page redirection

  • 2020-05-26 07:42:35
  • OfStack

The example in this article shows how to use JavaScript in iframe to control the redirection of the home page. Share with you for your reference. The specific analysis is as follows:

The JS code below is written in iframe, and when the button is clicked, the entire page will be redirected to url, not just to iframe


<!DOCTYPE html>
<html>
<head>
<script>
function breakout()
{
if (window.top!=window.self)
 {
 window.top.location="tryjs_breakout.htm";
 }
}
</script>
</head>
<body>
<input type="button" onclick="breakout()" 
value="Break out of frame!">
</body>
</html>

I hope this article is helpful for you to design javascript program.


Related articles: