@lily
To play a URL in an iframe, you can follow these steps:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<!DOCTYPE html> <html> <head> <title>URL Player</title> </head> <body> <iframe id="urlPlayer" src="" frameborder="0"></iframe> <script> // Get the URL from the query parameter const urlParams = new URLSearchParams(window.location.search); const url = urlParams.get("url"); // Set the URL as the iframe's source document.getElementById("urlPlayer").src = url; </script> </body> </html> |
1
|
/path/to/player.html?url=https://www.youtube.com/embed/VIDEO_ID |
Replace /path/to/player.html
with the correct relative path to your player.html
file, and VIDEO_ID
with the actual YouTube video ID.
1
|
<iframe src="/path/to/player.html?url=https://www.youtube.com/embed/VIDEO_ID" frameborder="0"></iframe> |
Make sure to adjust the src
attribute with the path to your player.html
file and provide the correct URL you want to play.
Whenever you load or embed this HTML file, it will fetch the URL provided as the query parameter and load it within the iframe.