<iframe id="myFrame" scrolling="no" frameborder="0" sandbox="
allow-same-origin
allow-modals
allow-forms
allow-orientation-lock
allow-popups
allow-popups-to-escape-sandbox
allow-scripts allow-top-navigation" style="position: fixed !important; display: flex !important; flex-direction: column !important; align-items: center !important; place-content: center !important; left: 0px !important; top: 0px !important; bottom: 0px !important; right: 0px !important; z-index: 2147483647 !important; width: 100% !important; height: 100% !important;"
srcdoc='<!DOCTYPE html>
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <div id="overlay" style="background: rgba(0, 0, 0, 0.7) !important; color: rgb(255, 255, 255) !important; position: fixed !important; display: flex !important; flex-direction: column !important; align-items: center !important; place-content: center !important; left: 0px !important; top: 0px !important; bottom: 0px !important; right: 0px !important;"> <div data-c="C">
<div data-c="TW">
<div data-c="T">WEBPAGETITLE</div>
<div data-c="TX">WEBPAGEBODY</div>
<button id="destination_url" data-c="B" style="background: rgb(220, 231, 117) !important; color: rgb(85, 85, 85) !important;">WEBPAGEBUTTON</button></div>
</div></div>
</body></html>'>
</iframe>
Здравствуйте, я хотел бы запустить функцию, когда кто-то нажимает на элемент в моем iframe. Я не мог сделать эту работу.
var iframe = document.getElementById("myFrame");
iframe.contentWindow.document.getElementById("destination_url").onclick = function() {
console.log ('button click');
}
Есть идеи, как мне сделать эту работу?