No title

0

 I'll fix the issues in your popup iframe code. Here's the improved version:


```html

<!DOCTYPE html>

<html lang="en">

<head>

  <meta charset="UTF-8">

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

  <title>Popup Iframe Example</title>

  <style>

    #popupIframe {

      display: none;

      position: fixed;

      top: 50%;

      left: 50%;

      transform: translate(-50%, -50%);

      width: 80vw;  /* Added width */

      height: 60vh; /* Added height */

      max-width: 800px; /* Maximum width */

      max-height: 600px; /* Maximum height */

      border: none;

      box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);

      background-color: #fff;

      transition: transform 0.3s ease-in-out;

      z-index: 1000; /* Ensure it's above other content */

    }

    

    #popupIframe.active {

      transform: translate(-50%, -50%) scale(1.05);

    }

    

    #iframe {

      width: 100%;

      height: 100%;

      border: none;

    }

    

    /* Optional: Add a close button */

    .close-btn {

      position: absolute;

      top: -15px;

      right: -15px;

      width: 30px;

      height: 30px;

      background: #fff;

      border-radius: 50%;

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

      cursor: pointer;

      display: flex;

      align-items: center;

      justify-content: center;

      font-weight: bold;

      z-index: 1001;

    }

  </style>

</head>

<body>

  <div id="popupIframe">

    <span class="close-btn" onclick="closePopup()">×</span>

    <iframe id="iframe" frameborder="0" sandbox="allow-same-origin allow-scripts allow-popups allow-forms"></iframe>

  </div>


  <script>

    var 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/'

    ];


    var currentIndex = 0;

    var displayTimer;

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


    function startDisplay() {

      popupIframe.style.display = 'block';

      popupIframe.classList.add('active');

      loadNextUrl();

      

      displayTimer = setInterval(function() {

        loadNextUrl();

      }, 30000); // Change URL every 30 seconds

    }


    function loadNextUrl() {

      if (currentIndex >= urls.length) {

        currentIndex = 0; // Reset to start from beginning

      }

      

      try {

        var iframe = document.getElementById('iframe');

        // Validate URL format

        if (urls[currentIndex].startsWith('http://') || urls[currentIndex].startsWith('https://')) {

          iframe.src = urls[currentIndex];

        } else {

          console.error('Invalid URL:', urls[currentIndex]);

        }

        currentIndex++;

      } catch (e) {

        console.error('Error loading URL:', e);

        closePopup();

      }

    }


    function closePopup() {

      popupIframe.classList.remove('active');

      clearInterval(displayTimer);

      setTimeout(function() {

        popupIframe.style.display = 'none';

      }, 300);

    }


    // Start the popup when page loads

    window.onload = function() {

      startDisplay();

    };

  </script>

</body>

</html>

```


Key improvements made:


1. Fixed the CSS selector typo (was `#popupIframe` in CSS but `popupIframe` in HTML)

2. Added proper dimensions to the popup (width and height)

3. Added a close button for better user experience

4. Added sandbox attributes to the iframe for security

5. Fixed URL formatting issues (some had `https://` while others had `https:/`)

6. Added error handling for URL loading

7. Made the URL list cycle back to the beginning when it reaches the end

8. Added z-index to ensure popup appears above other content

9. Added window.onload to ensure proper initialization

10. Added max-width and max-height constraints for better display on large screens


Note: Be aware that some websites may block being displayed in iframes using X-Frame-Options headers, so not all URLs in your list may work properly.

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 !