My “isMMobile ()” function is detecting desktop user agent as mobile












0















What's this device? My function is detecting this device as mobile



"Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko"



function isMMobile() {

var device_agent = navigator.userAgent.toLowerCase();
if (/android|webos|iphone|ipad|ipod|blackberry|windows phone|opera mini|iemobile|tablet|nokia|kindle|mobile/i.test(device_agent)) {
return true;
}

if (window.DocumentTouch && document instanceof window.DocumentTouch) {
return true;
}

if (typeof window.orientation === "number" ||
'ontouchstart' in window ||
window.ontouchstart ||
'ontouchstart' in document.documentElement ||
"ontouch" in window ||
window.onmsgesturechange ||
window.navigator.msMaxTouchPoints ||
window.navigator.MaxTouchPoints > 0) {
return true;
}

return false;
}

var innerw = window.innerWidth || document.documentElement.clientWidth;
var ismob = isMMobile();


Data sent via ajax:



ismob=yes&innerw=800









share|improve this question



























    0















    What's this device? My function is detecting this device as mobile



    "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko"



    function isMMobile() {

    var device_agent = navigator.userAgent.toLowerCase();
    if (/android|webos|iphone|ipad|ipod|blackberry|windows phone|opera mini|iemobile|tablet|nokia|kindle|mobile/i.test(device_agent)) {
    return true;
    }

    if (window.DocumentTouch && document instanceof window.DocumentTouch) {
    return true;
    }

    if (typeof window.orientation === "number" ||
    'ontouchstart' in window ||
    window.ontouchstart ||
    'ontouchstart' in document.documentElement ||
    "ontouch" in window ||
    window.onmsgesturechange ||
    window.navigator.msMaxTouchPoints ||
    window.navigator.MaxTouchPoints > 0) {
    return true;
    }

    return false;
    }

    var innerw = window.innerWidth || document.documentElement.clientWidth;
    var ismob = isMMobile();


    Data sent via ajax:



    ismob=yes&innerw=800









    share|improve this question

























      0












      0








      0








      What's this device? My function is detecting this device as mobile



      "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko"



      function isMMobile() {

      var device_agent = navigator.userAgent.toLowerCase();
      if (/android|webos|iphone|ipad|ipod|blackberry|windows phone|opera mini|iemobile|tablet|nokia|kindle|mobile/i.test(device_agent)) {
      return true;
      }

      if (window.DocumentTouch && document instanceof window.DocumentTouch) {
      return true;
      }

      if (typeof window.orientation === "number" ||
      'ontouchstart' in window ||
      window.ontouchstart ||
      'ontouchstart' in document.documentElement ||
      "ontouch" in window ||
      window.onmsgesturechange ||
      window.navigator.msMaxTouchPoints ||
      window.navigator.MaxTouchPoints > 0) {
      return true;
      }

      return false;
      }

      var innerw = window.innerWidth || document.documentElement.clientWidth;
      var ismob = isMMobile();


      Data sent via ajax:



      ismob=yes&innerw=800









      share|improve this question














      What's this device? My function is detecting this device as mobile



      "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko"



      function isMMobile() {

      var device_agent = navigator.userAgent.toLowerCase();
      if (/android|webos|iphone|ipad|ipod|blackberry|windows phone|opera mini|iemobile|tablet|nokia|kindle|mobile/i.test(device_agent)) {
      return true;
      }

      if (window.DocumentTouch && document instanceof window.DocumentTouch) {
      return true;
      }

      if (typeof window.orientation === "number" ||
      'ontouchstart' in window ||
      window.ontouchstart ||
      'ontouchstart' in document.documentElement ||
      "ontouch" in window ||
      window.onmsgesturechange ||
      window.navigator.msMaxTouchPoints ||
      window.navigator.MaxTouchPoints > 0) {
      return true;
      }

      return false;
      }

      var innerw = window.innerWidth || document.documentElement.clientWidth;
      var ismob = isMMobile();


      Data sent via ajax:



      ismob=yes&innerw=800






      javascript mobile






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 22 '18 at 23:23









      MarceloMarcelo

      1




      1
























          1 Answer
          1






          active

          oldest

          votes


















          0














          That is IE 11 on Windows 7, with a touchscreen. Most windows laptops now have touch (and have for a while) so if your logic is basically “touch == mobile” then you will misidentify a lot of devices. There are a lot of mobile detection scripts out there, which also helps because someone else has to keep up with the new user agents and devices. If you can, let them deal with the headaches in detection!






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439031%2fmy-ismmobile-function-is-detecting-desktop-user-agent-as-mobile%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            That is IE 11 on Windows 7, with a touchscreen. Most windows laptops now have touch (and have for a while) so if your logic is basically “touch == mobile” then you will misidentify a lot of devices. There are a lot of mobile detection scripts out there, which also helps because someone else has to keep up with the new user agents and devices. If you can, let them deal with the headaches in detection!






            share|improve this answer




























              0














              That is IE 11 on Windows 7, with a touchscreen. Most windows laptops now have touch (and have for a while) so if your logic is basically “touch == mobile” then you will misidentify a lot of devices. There are a lot of mobile detection scripts out there, which also helps because someone else has to keep up with the new user agents and devices. If you can, let them deal with the headaches in detection!






              share|improve this answer


























                0












                0








                0







                That is IE 11 on Windows 7, with a touchscreen. Most windows laptops now have touch (and have for a while) so if your logic is basically “touch == mobile” then you will misidentify a lot of devices. There are a lot of mobile detection scripts out there, which also helps because someone else has to keep up with the new user agents and devices. If you can, let them deal with the headaches in detection!






                share|improve this answer













                That is IE 11 on Windows 7, with a touchscreen. Most windows laptops now have touch (and have for a while) so if your logic is basically “touch == mobile” then you will misidentify a lot of devices. There are a lot of mobile detection scripts out there, which also helps because someone else has to keep up with the new user agents and devices. If you can, let them deal with the headaches in detection!







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 22 '18 at 23:44









                mherzigmherzig

                782818




                782818






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439031%2fmy-ismmobile-function-is-detecting-desktop-user-agent-as-mobile%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Wiesbaden

                    Marschland

                    Dieringhausen