Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

When i click the button , It taking another function than the actual clicked function

when i click adult button , href should take me to link-1 and when i click adult and children button it should take me to link-2 , but which ever button i click it taking me to link-1 only , as im new to development , im unable to figure this out , can any one help me with this please , below i have added my html and script both , one more doubt is , when i give script from app.js windows.open is not working , it working only when i give from same html file , may i know why ?

<div class=" my-3">
                <a target="_blank" class="btn btn-outline-dark btn-h btn-block mx-2 btn-promo">
                  <button data-bs-toggle="modal" data-bs-target="#exampleModal" class="link-text" onclick="adult()">
                    Adult
                  </button>
                </a>
                <a target="_blank" class="btn btn-outline-dark btn-h btn-block mx-2 btn-promo">
                  <button data-bs-toggle="modal" data-bs-target="#exampleModal" class="link-text" onclick="adultChild()">
                  Adult & Child
                  </button>
                </a>
              </div>
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">Redirecting Alert</h5>
            <button type="button" onclick="reload()" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
          </div>
          <div class="modal-body">
            Now you are redirecting to our partner site. <br><br>
            
          </div>
        </div>
      </div>
    </div>
<!-- Adult button Script -->
  <script>
    setTimeout (function adult() {
      var win = window.open();
      win.location = "www.link-1.com", "_blank";
      win.opener = null;
      win.blur();
      window.focus();
    },7000,false)
  </script>

  <!-- Adult&children button Script -->
  <script>
    setTimeout (function adultChild() {
      var win = window.open();
      win.location = "www.link-2.com", "_blank";
      win.opener = null;
      win.blur();
      window.focus();
    },7000)
  </script>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<div class=" my-3">
                <a target="_blank" class="btn btn-outline-dark btn-h btn-block mx-2 btn-promo">
                  <button data-bs-toggle="modal" data-bs-target="#exampleModal" class="link-text" onclick="adult()">
                    Adult
                  </button>
                </a>
                <a target="_blank" class="btn btn-outline-dark btn-h btn-block mx-2 btn-promo">
                  <button data-bs-toggle="modal" data-bs-target="#exampleModal" class="link-text" onclick="adultChild()">
                  Adult & Child
                  </button>
                </a>
              </div>

<script>
    function newadult(){
      var win = window.open();
      win.location = "www.link-1.com","_blank";
      win.opener = null;
      win.blur();
      window.focus();
    }


    function adult(){
      setTimeout(newadult,700)
    }


    function newadultChild(){
      var win = window.open();
      win.location = "www.link-2.com", "_blank";
      win.opener = null;
      win.blur();
      window.focus();
    }

    function adultChild(){
       setTimeout(newadultChild,700)
    }
      
  </script>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading