-1

On my site, i have to tab twice then any link will open, issue is in both safari and chrome. I have applied Solution :: jQuery( '.pkg_book-btn-wrapper a' ).on('click touchend touchstart',function(e) { window.location = jQuery(this).attr("href"); e.preventDefault(); }); But it works on some time only. Also not working scroll when opening link, url like, www.xyz.com/#book-now Some time scroll but its goes to footer and anywhere but did not go to prefect id. Please solve this, i am facing this issue too long time.

2 Answers2

0

Though, the issue you are facing was not well stated, the tap event conflict is likely to be in your own code. See this answer if it would make a change. It uses a doubletap function;

var mylatesttap;
function doubletap() {

var now = new Date().getTime();
var timesince = now - mylatesttap;
if((timesince < 600) && (timesince > 0)){

// double tap "You can maybe use preventdefault action from here"

}else{
        // too much time to be a doubletap
     }

mylatesttap = new Date().getTime();

}
yuxufabio
  • 51
  • 5
0

Some mobile browsers register only a touch event on the first tap, and not a click event. You can modify this as you need for your use case...

window.addEventListener('load', ()=>{
    let links = document.getElementsByTagName('a')
    for(let i=0; links[i]; i++) {
        // Converts a touch event to a click event
        links[i].addEventListener('touchend', (event)=>{
            event.target.click();
        })
    }
})
Shane McCurdy
  • 2,203
  • 1
  • 10
  • 11