我使用的网站没有视频播放速度。我想提高速度。但是问题是视频在iframe中。这是我当前粘贴到chrome控制台中的代码:
// this works
iframe = document.querySelector('iframe')
// this does not work even though there is a video element inside the frame, it can't find it.
iframe.querySelector('video').playbackRate = 1.2
如果我手动在iframe中单击并运行document.querySelector('video').playbackRate = 1.2
,它可以工作,但是在框架中单击以运行代码很麻烦。
您需要使用该contentDocument
属性来访问iframe中的文档:
iframe = document.querySelector('iframe').contentDocument
iframe.querySelector('video').playbackRate = 1.2
请注意,这仅在iframe与顶级文档位于同一域中时才有效。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句