Determine if user navigated from mobile Safari

后端 未结 12 689
情书的邮戳
情书的邮戳 2020-11-29 19:40

I have an app, and I\'d like to redirect the users to different pages based on where they are navigating from.

If navigating from web clip, do not redirect. If navig

12条回答
  •  眼角桃花
    2020-11-29 20:22

    I know this is an old thread, but I'd like to share my solution with you guys.

    I needed to detect when an user navigates from Desktop Safari (Because we're in middle 2017, and Apple hasn't give any support for input[type="date"] YET...

    So, I made a fallback custom datepicker for it) . But only applies to safari in desktop because that input type works fine in mobile Safari. So, I made this Regex to only detect desktop Safari. I already tested it and it doesn't match with Opera, Chrome, Firefox or Safari Mobile.

    Hope it may help some of you guys.

    if(userAgent.match(/^(?!.*chrome).(?!.*mobile).(?!.*firefox).(?!.*iPad).(?!.*iPhone).*safari.*$/i)){
      $('input[type="date"]').each(function(){
        $(this).BitmallDatePicker();
      })
    }
    

提交回复
热议问题