Changing parent window's URL from IFrame - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:IFrame

Description

Changing parent window's URL from IFrame

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <script>
function clickit() {//from   w w w .j  av  a2  s  .c o m
  parent.postMessage('redirect:http://www.google.com', 'http://server1');
}

      </script> 
      <p>This should be in an iFrame!</p> 
      <p>
         <a href="http://www.google.com" target="_parent">normal link</a>
      </p> 
      <p>
         <a href="javascript:clickit()">javascript link</a>
      </p> 
   </body>
</html>

Related Tutorials