如何与iFrame中的标记进行交互

时间:2012-06-23 10:42:41

标签: javascript dom iframe browser

说我有这样的代码:

<html>
   <head>
   </head>
 <body>
      <iframe>
          <script>
   //execute javascript here to append another piece of javascript in parent body tag
          </script>
      </iframe>
 </body>
</html>

现在我想在iFrame中执行一些javascript,在父体标签中添加另一段javascript。

1 个答案:

答案 0 :(得分:1)

如果iframe属于主窗口的同一个域,则只需执行

即可
top.functionToBeCalled(argument);