假设您的iFrame的ID为“ targetFrame”,而您要调用的函数为targetFunction()
:
document.getElementById('targetFrame').contentWindow.targetFunction();
您也可以使用window.frames
代替访问框架document.getElementById
。
// this option does not work in most of latest versions of chrome and Firefox
window.frames[0].frameElement.contentWindow.targetFunction();