且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在iframe中获取点击事件触发父框架中的警报

更新时间:2023-10-28 22:14:46

为了使您的函数对iframe可见,您需要将其声明为window对象的成员:

In order to make your function visible to the iframe you need to declare it as a member of the window object:

$(document).ready(function() {
    window.triggerAlert = function (){
        alert('iFrame button has been clicked');
    }
});