I have 2 buttons on a pop up ad and depending on what they select do totally different things. However they dont seem to work on mobile. I cant figure out and alternative. Also I would like a delay of like 2 sec before the action but im not sure how to use timeout in this situation. I tired to use onkeyup but that did not work nor does onclick.
<div class="modal-content">
<span class="close">×</span>
<div class="radcen">
<input type="radio" id="yes" value="Yes" onchange="window.location.href = 'https://www.example.com/';"><label class="free-label four col" for="yes">Yes</label>
<input type="radio"id="no" value="No" onchange="myModal.style.display = 'none'"><label class="basic-label four col" for="no">No</label>
</div>
</div><!-- Modal content -->
and the script
var modal = document.getElementById("myModal");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When page loads display pop up
window.onload = 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";
}