• 07-06-2018, 20:08:29
    #1
    Selam Arkadaşlar
    Aşağıdaki popup penceresine süre eklemek istiyorum butona tıklandığında popup açılıyor 3 saniye sonrada kapansın.


    <h2>Modal Example</h2>
    <!-- Trigger/Open The Modal -->
    <button id="myBtn">Open Modal</button>
    
    <!-- The Modal -->
    <div id="myModal" class="modal">
    
      <!-- Modal content -->
      <div class="modal-content">
        <span class="close">&times;</span>
        <p>Some text in the Modal..</p>
      </div>
    
    </div>
    
    <script>
    // Get the modal
    var modal = document.getElementById('myModal');
    
    // Get the button that opens the modal
    var btn = document.getElementById("myBtn");
    
    // Get the <span> element that closes the modal
    var span = document.getElementsByClassName("close")[0];
    
    // When the user clicks the button, open the modal
    btn.onclick = function() {
        modal.style.display = "block";
    }
    
    // When the user clicks on <span> (x), close the modal
    span.onclick = function() {
        modal.style.display = "none";
    }
    
    // When the user clicks anywhere outside of the modal, close it
    window.onclick = function(event) {
        if (event.target == modal) {
            modal.style.display = "none";
        }
    }
    </script>
  • 07-06-2018, 20:47:05
    #2
    Ertenya adlı üyeden alıntı: mesajı görüntüle
    Selam Arkadaşlar



    Aşağıdaki popup penceresine süre eklemek istiyorum butona tıklandığında popup açılıyor 3 saniye sonrada kapansın.



    <h2>Modal Example</h2>
    <!-- Trigger/Open The Modal -->
    <button id="myBtn">Open Modal</button>
    
    <!-- The Modal -->
    <div id="myModal" class="modal">
    
      <!-- Modal content -->
      <div class="modal-content">
        <span class="close">&times;</span>
        <p>Some text in the Modal..</p>
      </div>
    
    </div>
    
    <script>
    // Get the modal
    var modal = document.getElementById('myModal');
    
    // Get the button that opens the modal
    var btn = document.getElementById("myBtn");
    
    // Get the <span> element that closes the modal
    var span = document.getElementsByClassName("close")[0];
    
    // When the user clicks the button, open the modal
    btn.onclick = function() {
        modal.style.display = "block";
    }
    
    // When the user clicks on <span> (x), close the modal
    span.onclick = function() {
        modal.style.display = "none";
    }
    
    // When the user clicks anywhere outside of the modal, close it
    window.onclick = function(event) {
        if (event.target == modal) {
            modal.style.display = "none";
        }
    }
    </script>
    set timeout kullan 3sn sonra divisilsin ve ya kapatsin
  • 07-06-2018, 21:37:06
    #3
    @theykk;

    Set timeout nereye yazmalı ve jsden pek anlamıyorum hocam yazılması gereken yeri biliyorsan yazar mısın?

    <script>
    // Get the modal
    var modal = document.getElementById('myModal');
    
    // Get the button that opens the modal
    var btn = document.getElementById("myBtn");
    
    // Get the <span> element that closes the modal
    var span = document.getElementsByClassName("close")[0];
    
    // When the user clicks the button, open the modal
    btn.onclick = function() {
        modal.style.display = "block";
    }
    
    // When the user clicks on <span> (x), close the modal
    span.onclick = function() {
        modal.style.display = "none";
    }
    
    // When the user clicks anywhere outside of the modal, close it
    window.onclick = function(event) {
        if (event.target == modal) {
            modal.style.display = "none";
        }
    }
    </script>
  • 07-06-2018, 21:38:44
    #4
    Ertenya adlı üyeden alıntı: mesajı görüntüle
    @theykk;

    Set timeout nereye yazmalı ve jsden pek anlamıyorum hocam yazılması gereken yeri biliyorsan yazar mısın?

    <script>
    // Get the modal
    var modal = document.getElementById('myModal');
    
    // Get the button that opens the modal
    var btn = document.getElementById("myBtn");
    
    // Get the <span> element that closes the modal
    var span = document.getElementsByClassName("close")[0];
    
    // When the user clicks the button, open the modal
    btn.onclick = function() {
        modal.style.display = "block";
    }
    
    // When the user clicks on <span> (x), close the modal
    span.onclick = function() {
        modal.style.display = "none";
    }
    
    // When the user clicks anywhere outside of the modal, close it
    window.onclick = function(event) {
        if (event.target == modal) {
            modal.style.display = "none";
        }
    }
    </script>
    btn.onclick = function() {
    modal.style.display = "block";
    }
  • 07-06-2018, 22:21:58
    #5
    @theykk;

    Çok teşekktüler hocam yapabildim.
  • 07-06-2018, 22:50:21
    #6
    Ertenya adlı üyeden alıntı: mesajı görüntüle
    @theykk;

    Çok teşekktüler hocam yapabildim.
    rica ederim bir r10+ like alirim