WICG / document-picture-in-picture

https://wicg.github.io/document-picture-in-picture/
Other
56 stars 9 forks source link

Javascript and Events Support #86

Closed DiodeDan closed 7 months ago

DiodeDan commented 1 year ago

Do PiP windows have the ability to insert JS into them? For example, if I want to display a test alert: pipWindow.innerHTML += "<script>alert("hello world")</script>"

I tried this on Chrome 114 (Mac OS) with the experimental flags on, but it did not seem to recognize the JS.

Thanks!

steimelchrome commented 1 year ago

There is no innerHTML attribute on a Window object, so changing innerHTML would require pipWindow.document.body.innerHTML.

That said, you can't insert script via innerHTML for any document, including a PiP document (I believe this is for security reasons). Here is a tutorial I found giving more details: https://www.tutorialspoint.com/can-scripts-be-inserted-with-innerhtml#:~:text=Inserting%20a%20script%20with%20innerHTML&text=We%20cannot%20use%20the%20innerHTML,has%20to%20add%20a%20script.