📜  使用 javascript 控制 iframe 元素 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:47.035000             🧑  作者: Mango

代码示例2


// Get the iframe
const iFrame = document.getElementById('myIFrame');

// Let's say that you want to access a button with the ID `'myButton'`,
// you can access via the following code:
const buttonInIFrame = iFrame.contentWindow.document.getElementById('myButton');

// If you need to call a function in the iframe, you can call it as follows:
iFrame.contentWindow.yourFunction();