2014年3月18日 星期二

javascript-iframe-call-parent-click

in the parent window:
  1. <script>
  2. function OnFrameButtonClick () {
  3. alert ("You clicked on a button in the frame");
  4. }
  5. </script>
in the child frame window:
  1. <head>
  2. <script>
  3. function OnButtonClick () {
  4. // check whether the parent window and the OnFrameButtonClick method exist
  5. if (window.parent && parent.OnFrameButtonClick) {
  6. parent.OnFrameButtonClick ();
  7. }
  8. }
  9. </script>
  10. </head>
  11. <body>
  12. <button onclick="OnButtonClick ()">Test</button>
  13. </body>
You can find further examples on the following sites:

沒有留言:

張貼留言