Closing and redirecting a modal

1396
2
Jump to solution
04-08-2022 10:21 AM
AJ_devaccount
Occasional Contributor

Is it possible to create a button at the end of a modal that closes it, but also redirects the user to a different page? Basically the modal has a disclaimer, where at the end the user has to "Agree" with the terms, which should close the modal, but also open up a different page. 

Thank you!

Edit: this code should work in Bootstrap 4, unfortunately I couldn't find a Bootstrap 3 version. 

<a href="link" class="btn btn-primary" target="_blank" data-dismiss="modal">I Agree</a>

 

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
BrianRollison
Esri Contributor

Hi @AJ_devaccount - not at this time, please log an ENH request with support or post to ArcGIS Ideas. This way the community will be able to follow/upvote your request.

View solution in original post

0 Kudos
2 Replies
BrianRollison
Esri Contributor

Hi @AJ_devaccount - not at this time, please log an ENH request with support or post to ArcGIS Ideas. This way the community will be able to follow/upvote your request.

0 Kudos
nehakakar
New Contributor

Try this on Bootstrap 3 ..

<!-- Modal content -->
<div class="modal" id="myModal">
  <div class="modal-dialog">
    <div class="modal-content">
      <!-- Modal body -->
      <div class="modal-body">
        <!-- Disclaimer content goes here -->
      </div>
      
      <!-- Modal footer -->
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <a href="link" class="btn btn-primary" id="agreeButton">I Agree</a>
      </div>
    </div>
  </div>
</div>

<!-- Button to trigger the modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">Open Modal</button>

<!-- JavaScript to handle the "I Agree" button click -->
<script>
document.getElementById('agreeButton').addEventListener('click', function() {
  // Redirect the user to the specified link
  window.location.href = 'link';
});
</script>
0 Kudos