检查inframe函数内的函数

时间:2016-06-27 09:43:21

标签: jquery ajax iframe click

我想执行一个函数来更新iframe点击脚本

<script>
    var monitor = setInterval(function() {
        var elem = document.activeElement;
        if (elem && elem.tagName == 'IFRAME') {
            message.innerHTML = 'Clicked'
            // here ajax execute, but doesn't work, it loads the whole script without clicking it.
            clearInterval(monitor);
        }
    }, 100);
</script>

<div id="framerefresh">
    <iframe rel="nofollow" src="adsense.htm" id="iframe" name="frame1" scrolling="no" frameborder="no" align="center" height = "250px" width = "300px"></iframe>
    <div id="message"></div>
</div>

我真的非常需要一些帮助。我想在iframe内部发生点击时运行更新查询。

1 个答案:

答案 0 :(得分:0)

您可以尝试以下

<script type = "text/javascript">
     $(document).ready(function(){
         $('#iframe').on('click', function(event) { 
              // Your ajax call
          });
       });
</script>