我child.html有一个可以使用脚本单击的按钮,$('[value="Submit"]').click();
我想从中调用它parent.html
像这样的东西:
var popUp = window.open('https://child.html');
popUp.$('[value="Submit"]').click();//这条线应该是固定的
怎么可以这样呢?
在parent.html中使用此代码来单击按钮:
let child = window.open('child.html');
let doClick = () => child.document.getElementById('my-button').click();
child.addEventListener('load', doClick(), true);
Run Code Online (Sandbox Code Playgroud)
这就是你想要的...但我的建议是在 child 上创建函数并使用 window.postMessage API 来触发它...