htmlContent = ` <style> #helpBtn { position: absolute; top: 20px; right: 20px; width: 30px; height: 30px; border-radius: 50%; background-color: #007BFF; color: white; font-size: 15px; text-align: center; line-height: 30px; cursor: pointer; z-index: 1000; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); } #videoModal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.8); z-index: 999; justify-content: center; align-items: center; } #videoContent { position: relative; width: 80%; max-width: 800px; aspect-ratio: 16 / 9; background-color: black; } #closeBtn { position: absolute; top: -40px; right: 0; font-size: 30px; color: white; cursor: pointer; background: none; border: none; } iframe { width: 100%; height: 100%; border: none; } </style> <!-- Floating button --> <div id="helpBtn">?</div> <!-- Video modal --> <div id="videoModal"> <div id="videoContent"> <button id="closeBtn">×</button> <iframe src="" id="youtubeFrame" allowfullscreen></iframe> </div> </div> `; container = document.getElementById("helpVideoButton"); container.innerHTML = htmlContent; (function() { const helpBtn = document.getElementById('helpBtn'); const videoModal = document.getElementById('videoModal'); const closeBtn = document.getElementById('closeBtn'); const youtubeFrame = document.getElementById('youtubeFrame'); const youtubeLink = "https://www.youtube.com/embed/en2i1rvWGPI"; helpBtn.onclick = () => { youtubeFrame.src = youtubeLink + "?autoplay=1"; videoModal.style.display = "flex"; }; closeBtn.onclick = () => { youtubeFrame.src = ""; videoModal.style.display = "none"; }; })(); ;
No comments:
Post a Comment