JS failed to get the event listening of the element in iframe

CSDN Q & A 2021-12-30 07:17:58 阅读数:286

js failed event listening element

On the research page js There was a problem when , Use getEventListener Can't get iframe Event listening for inner elements

ifm=document.getElementById('iframe');// Returned a iframeifmAr=ifm.contentDocument.getElementsByTagName('iframe')// Back to iframe Inside iframe Array video=ifmAr[0].contentDocument.getElementById('video_html5_api')// Returned a videogetEventListeners(ifm)// You can get the event listener getEventListeners(ifmAr[0])// Failed to get event listener , An empty object was returned getEventListeners(video)// Similarly, you can't get 


Searched a lot of related content , There is no way to solve the problem , If opened F12 Select that... Directly on the web page video, So you can get , It's no use , People are numb

I hope I can find the error in my code , Achieve the goal of obtaining iframe Event listening for the next element !!

Refer to the answer 1:

Can no longer top Context acquisition iframe in dom Events , The development tool needs to switch to the corresponding iframe Execute the code after the context of , Note that the context is directly iframe, No need to start from the parent page ifm.contentDocument.getElementsByTagName So get dom, direct document.getElementsByTagName


Helpful or enlightening. Please click here 【 Adopt the answer 】, thank you ~~

Refer to the answer 2:

Refer to the answer 3:

monitor iframe Internal events can't be done , Can only monitor iframe The event of the form , At most, the parameters are transmitted in some way

Refer to the answer 4:
版权声明:本文为[CSDN Q & A]所创,转载请带上原文链接,感谢。 https://primo.wiki/2021/12/202112300717559780.html