popup with overlay

0

 Here's another type of popup iframe implementation with different styling and behavior. This version includes:


1. A modal-style popup with overlay

2. Navigation buttons to move between URLs

3. Auto-rotation with pause/play controls

4. Responsive sizing

5. Better visual presentation


```html

<!DOCTYPE html>

<html lang="en">

<head>

  <meta charset="UTF-8">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>Advanced Popup Iframe Rotator</title>

  <style>

    /* Overlay */

    .popup-overlay {

      display: none;

      position: fixed;

      top: 0;

      left: 0;

      width: 100%;

      height: 100%;

      background: rgba(0, 0, 0, 0.7);

      z-index: 1000;

      justify-content: center;

      align-items: center;

    }

    

    /* Popup container */

    .popup-container {

      width: 90%;

      max-width: 900px;

      height: 80vh;

      background: white;

      border-radius: 10px;

      box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);

      overflow: hidden;

      position: relative;

      transform: scale(0.9);

      opacity: 0;

      transition: all 0.3s ease;

    }

    

    .popup-container.active {

      transform: scale(1);

      opacity: 1;

    }

    

    /* Iframe styling */

    .popup-iframe {

      width: 100%;

      height: 100%;

      border: none;

    }

    

    /* Controls */

    .popup-controls {

      position: absolute;

      bottom: 0;

      left: 0;

      width: 100%;

      background: rgba(0, 0, 0, 0.7);

      padding: 10px;

      display: flex;

      justify-content: center;

      gap: 15px;

    }

    

    .control-btn {

      background: #fff;

      border: none;

      border-radius: 50%;

      width: 40px;

      height: 40px;

      cursor: pointer;

      display: flex;

      align-items: center;

      justify-content: center;

      font-size: 18px;

      transition: all 0.2s;

    }

    

    .control-btn:hover {

      background: #f0f0f0;

      transform: scale(1.1);

    }

    

    .close-btn {

      position: absolute;

      top: 10px;

      right: 10px;

      background: rgba(0, 0, 0, 0.5);

      color: white;

      border: none;

      border-radius: 50%;

      width: 30px;

      height: 30px;

      cursor: pointer;

      font-size: 16px;

      z-index: 10;

    }

    

    .url-counter {

      color: white;

      font-family: Arial, sans-serif;

      display: flex;

      align-items: center;

    }

  </style>

</head>

<body>

  <!-- Popup structure -->

  <div class="popup-overlay" id="popupOverlay">

    <div class="popup-container" id="popupContainer">

      <button class="close-btn" id="closeBtn">×</button>

      <iframe class="popup-iframe" id="popupIframe" sandbox="allow-same-origin allow-scripts allow-popups allow-forms"></iframe>

      <div class="popup-controls">

        <button class="control-btn" id="prevBtn">◄</button>

        <button class="control-btn" id="playPauseBtn">❚❚</button>

        <button class="control-btn" id="nextBtn">►</button>

        <span class="url-counter" id="urlCounter">1/15</span>

      </div>

    </div>

  </div>


  <script>

    // URL list

    const urls = [

      'https://advertica13.blogspot.com/',

      'https://advertica12.blogspot.com/',

      'https://advertica08.blogspot.com/',

      'https://advertica07.blogspot.com/',

      'https://advertica06.blogspot.com/',

      'https://advertica18.blogspot.com/',

      'https://advertica19.blogspot.com/',

      'https://advertica17.blogspot.com/',

      'https://advertica16.blogspot.com/',

      'https://advertica15.blogspot.com/',

      'https://advertica14.blogspot.com/',

      'https://www.softmob.shop/',

      'https://advertica23.blogspot.com/',

      'https://advertica22.blogspot.com/',

      'https://advertica21.blogspot.com/',

      'https://advertica20.blogspot.com/',

      'https://www.softmod.shop/'

    ];


    // DOM elements

    const popupOverlay = document.getElementById('popupOverlay');

    const popupContainer = document.getElementById('popupContainer');

    const popupIframe = document.getElementById('popupIframe');

    const closeBtn = document.getElementById('closeBtn');

    const prevBtn = document.getElementById('prevBtn');

    const nextBtn = document.getElementById('nextBtn');

    const playPauseBtn = document.getElementById('playPauseBtn');

    const urlCounter = document.getElementById('urlCounter');


    // State variables

    let currentIndex = 0;

    let rotationInterval;

    let isPlaying = true;

    const rotationSpeed = 30000; // 30 seconds


    // Initialize popup

    function initPopup() {

      showPopup();

      loadCurrentUrl();

      startRotation();

      updateCounter();

    }


    // Show popup with animation

    function showPopup() {

      popupOverlay.style.display = 'flex';

      setTimeout(() => {

        popupContainer.classList.add('active');

      }, 10);

    }


    // Hide popup

    function hidePopup() {

      popupContainer.classList.remove('active');

      setTimeout(() => {

        popupOverlay.style.display = 'none';

      }, 300);

    }


    // Load current URL

    function loadCurrentUrl() {

      if (currentIndex >= 0 && currentIndex < urls.length) {

        popupIframe.src = urls[currentIndex];

      }

    }


    // Update URL counter

    function updateCounter() {

      urlCounter.textContent = `${currentIndex + 1}/${urls.length}`;

    }


    // Start URL rotation

    function startRotation() {

      if (rotationInterval) clearInterval(rotationInterval);

      rotationInterval = setInterval(() => {

        if (isPlaying) {

          nextUrl();

        }

      }, rotationSpeed);

    }


    // Go to next URL

    function nextUrl() {

      currentIndex = (currentIndex + 1) % urls.length;

      loadCurrentUrl();

      updateCounter();

    }


    // Go to previous URL

    function prevUrl() {

      currentIndex = (currentIndex - 1 + urls.length) % urls.length;

      loadCurrentUrl();

      updateCounter();

    }


    // Toggle play/pause

    function togglePlayPause() {

      isPlaying = !isPlaying;

      playPauseBtn.textContent = isPlaying ? '❚❚' : '►';

      if (isPlaying) {

        startRotation();

      }

    }


    // Event listeners

    closeBtn.addEventListener('click', hidePopup);

    prevBtn.addEventListener('click', () => {

      prevUrl();

      if (!isPlaying) startRotation(); // Restart rotation if paused

    });

    nextBtn.addEventListener('click', () => {

      nextUrl();

      if (!isPlaying) startRotation(); // Restart rotation if paused

    });

    playPauseBtn.addEventListener('click', togglePlayPause);


    // Start when page loads

    window.addEventListener('load', initPopup);


    // Close when clicking outside

    popupOverlay.addEventListener('click', (e) => {

      if (e.target === popupOverlay) {

        hidePopup();

      }

    });

  </script>

</body>

</html>

```


### Key Features of This Version:


1. **Modal Overlay**: Dark semi-transparent background that focuses attention on the popup

2. **Navigation Controls**:

   - Previous/Next buttons to manually navigate

   - Play/Pause button to control auto-rotation

   - Close button to dismiss the popup


3. **URL Counter**: Shows current position in the rotation (e.g., "3/15")


4. **Smooth Animations**:

   - Fade-in/out effects

   - Scale animation when appearing


5. **Responsive Design**:

   - Adapts to different screen sizes

   - Maximum width to prevent overly large popups


6. **Improved User Control**:

   - Users can pause the rotation to view a site longer

   - Manual navigation available

   - Clear close button


7. **Visual Polish**:

   - Rounded corners

   - Shadow effects

   - Clean control buttons


This implementation provides a more professional and user-friendly experience while maintaining all the functionality of your original script.

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !