3

I've written an event to open new browser tab (window.open) by jQuery like below:

$(document).on('touchstart click', '.myClass', {self: this}, function (e) {

    var mylink = e.data.self.validateDomValue(this, 'attr=data-affiliate')

    if(myLink)
    {
        window.open(mylink, '_blank');
    }
});

This scripts working well for windows, mac and iPad but the problem is arising for iPhone. The event is not firing for iPhone (version: 5, 6 and 7). What was my mistake? Any of your suggestion will be appreciated.

MH2K9
  • 11,951
  • 7
  • 32
  • 49

2 Answers2

2

Oh! Yes! I got the point. I need to use css cursor:pointer. That works for me.

if (/iP(hone|od|ad)/.test(navigator.platform)) 
{
    $(".myClass").css({"cursor":"pointer"});
}
MH2K9
  • 11,951
  • 7
  • 32
  • 49
0

use css cursor:pointer didn't work for me once the element I used was on 'position:fixed'. I added a 'click' event listener and it solved the case. Once I click on the element only one of the events is fired.

  • Hello and welcome to StackOverflow! Please add a few more details. In what versions of iOS/Safari did the trick the previous answer not work? – Ad5001 Jul 28 '21 at 09:54