Search This Blog

Thursday, May 16, 2019

Redirect parent window from an iframe action uisng Javascript

Welcome to  designer dairy blog, here we are going to  discuss how to Redirect parent window from an iframe action

Step1:

Example.html is the main page and  we are loading "example1.html" via an iframe tag.

Example.Html Mark-up

<html>
<head>
<body>
<iframe src="Example1.html"> </iframe>
</body>
</html>

Step2:

Example1.html  we have a button "Click Me", once the button is clicked, we have to redirect to url "www.google.com".

So we have to use window.top.location.href  to redirect parent window from an iframe action.

Html Mark-up - Example2.html

<script>
function changeurl()
{
window.top.location.href = "http://www.google.com";
}
</script>

<a href ="#"  id="accept" onclick="changeurl()"> Click Me </a>

Note: 

If your not using iframe tag, then u can use window.location.href to redirect parent window.

Step3:

Thanks for reading the article.Stay Tuned on www.webdesignersdairy.com  for more updates on Javascript.



No comments:

Post a Comment

Validating to select in sequencial order using angular

    < input type = "checkbox" (change) = "handleSelectTaskItem($event, taskItem)" [checked] = " taskItem . i...