📅 2025-12-07T20:57:08.476Z
👁️ 24 katselukertaa
🔓 Julkinen


  // Create modal elements
  const modal = document.createElement('div');
  const modalContent = document.createElement('div');
  const closeBtn = document.createElement('span');
  const iframe = document.createElement('iframe');

  // Style the modal
  modal.style.position = 'fixed';
  modal.style.top = '0';
  modal.style.left = '0';
  modal.style.width = '100%';
  modal.style.height = '100%';
  modal.style.backgroundColor = 'rgba(0,0,0,0.7)';
  modal.style.display = 'flex';
  modal.style.justifyContent = 'center';
  modal.style.alignItems = 'center';
  modal.style.zIndex = '9999';

  modalContent.style.position = 'relative';
  modalContent.style.width = '80%';
  modalContent.style.maxWidth = '800px';
  modalContent.style.backgroundColor = '#000';
  modalContent.style.paddingTop = '56.25%'; // 16:9 ratio
  modalContent.style.borderRadius = '8px';
  modalContent.style.overflow = 'hidden';

  // Style the close button
  closeBtn.innerHTML = '×';
  closeBtn.style.position = 'absolute';
  closeBtn.style.top = '10px';
  closeBtn.style.right = '20px';
  closeBtn.style.fontSize = '30px';
  closeBtn.style.color = '#fff';
  closeBtn.style.cursor = 'pointer';
  closeBtn.style.zIndex = '10';

  // Set up the iframe
  iframe.src = 'https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=1';
  iframe.style.position = 'absolute';
  iframe.style.top = '0';
  iframe.style.left = '0';
  iframe.style.width = '100%';
  iframe.style.height = '100%';
  iframe.style.border = '0';
  iframe.allow = 'autoplay; encrypted-media';

  // Close modal function
  closeBtn.onclick = () => document.body.removeChild(modal);
  modal.onclick = (e) => {
    if (e.target === modal) {
      document.body.removeChild(modal);
    }
  }

  // Assemble modal
  modalContent.appendChild(closeBtn);
  modalContent.appendChild(iframe);
  modal.appendChild(modalContent);
  document.body.appendChild(modal);