在html文件夹下有a.html, 我要在a.html里执行execScript让 index.html中的openFrameGroup里,name为frame_index_me的frame,执行frame它的setData()函数
//下面这块代码在frame_index_me.html里注意: setData() 函数不能放在apiready=function(){}里
function setData(id, name){
alert("这是我的id: " + id);
alert("这是我的name: " + name);
}
// 下面这块代码在a.html里
api.execScript({
name:'root', //这里root代表index.html
frameName: 'frame_index_me',
script: 'setData("' + id + '","' + name + '");'
//下面这块代码在frame_index_me.html里注意: setData() 函数不能放在apiready=function(){}里
function setData(id, name){
alert("这是我的id: " + id);
alert("这是我的name: " + name);
}
// 下面这块代码在a.html里
api.execScript({
name:'root', //这里root代表index.html
frameName: 'frame_index_me',
script: 'setData("' + id + '","' + name + '");'
});
原贴地址:https://community.apicloud.com/bbs/forum.php?mod=viewthread&tid=12458&highlight=execScript
本文介绍如何在HTML文件中通过API的execScript方法来调用指定iframe内的JavaScript函数。具体示例展示了从a.html文件调用index.html中名为frame_index_me的iframe内的setData函数的过程。
277

被折叠的 条评论
为什么被折叠?



