HTML - Switch Desktop and Mobile view is not working on browser resize











up vote
0
down vote

favorite












I have a web page that allows switching between Mobile/Desktop view. I use the below code to toggle between desktop and Mobile layouts.



$('meta[name="viewport"]').prop('content', 'width=device-width, initial-scale=1.0'); // Toggle code for Mobile View

$('meta[name="viewport"]').prop('content', 'width=1024'); // Toggle code for Desktop View


The above works perfectly in chrome device simulator mode. However, if I disable the device simulator and resize the desktop to Mobile width and try the toggle, it is not working. But the viewport content property changes as per the toggle code.



Update:




  1. Responsive design works perfectly in Mobile devices (Say, when width < n Pixels); The desktop and the Mobile view is switchable using a toggle button using the above-mentioned code.

  2. Responsive design works perfectly in Desktop Browser (When width resized to < n Pixels); The Desktop and Mobile view is not switchable. This is the issue.










share|improve this question

















This question has an open bounty worth +50
reputation from Gugan ending in 4 days.


The current answers do not contain enough detail.
















  • Did you tried with initial-scale=1.0? If you use Bootstrap, why you use two different layouts?
    – SilvioCro
    Nov 22 at 1:00












  • Did you try with .resize(). or try calling the same code within .resize().
    – vssadineni
    yesterday










  • Yes, I am calling the same code in resize().
    – Gugan
    yesterday















up vote
0
down vote

favorite












I have a web page that allows switching between Mobile/Desktop view. I use the below code to toggle between desktop and Mobile layouts.



$('meta[name="viewport"]').prop('content', 'width=device-width, initial-scale=1.0'); // Toggle code for Mobile View

$('meta[name="viewport"]').prop('content', 'width=1024'); // Toggle code for Desktop View


The above works perfectly in chrome device simulator mode. However, if I disable the device simulator and resize the desktop to Mobile width and try the toggle, it is not working. But the viewport content property changes as per the toggle code.



Update:




  1. Responsive design works perfectly in Mobile devices (Say, when width < n Pixels); The desktop and the Mobile view is switchable using a toggle button using the above-mentioned code.

  2. Responsive design works perfectly in Desktop Browser (When width resized to < n Pixels); The Desktop and Mobile view is not switchable. This is the issue.










share|improve this question

















This question has an open bounty worth +50
reputation from Gugan ending in 4 days.


The current answers do not contain enough detail.
















  • Did you tried with initial-scale=1.0? If you use Bootstrap, why you use two different layouts?
    – SilvioCro
    Nov 22 at 1:00












  • Did you try with .resize(). or try calling the same code within .resize().
    – vssadineni
    yesterday










  • Yes, I am calling the same code in resize().
    – Gugan
    yesterday













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a web page that allows switching between Mobile/Desktop view. I use the below code to toggle between desktop and Mobile layouts.



$('meta[name="viewport"]').prop('content', 'width=device-width, initial-scale=1.0'); // Toggle code for Mobile View

$('meta[name="viewport"]').prop('content', 'width=1024'); // Toggle code for Desktop View


The above works perfectly in chrome device simulator mode. However, if I disable the device simulator and resize the desktop to Mobile width and try the toggle, it is not working. But the viewport content property changes as per the toggle code.



Update:




  1. Responsive design works perfectly in Mobile devices (Say, when width < n Pixels); The desktop and the Mobile view is switchable using a toggle button using the above-mentioned code.

  2. Responsive design works perfectly in Desktop Browser (When width resized to < n Pixels); The Desktop and Mobile view is not switchable. This is the issue.










share|improve this question















I have a web page that allows switching between Mobile/Desktop view. I use the below code to toggle between desktop and Mobile layouts.



$('meta[name="viewport"]').prop('content', 'width=device-width, initial-scale=1.0'); // Toggle code for Mobile View

$('meta[name="viewport"]').prop('content', 'width=1024'); // Toggle code for Desktop View


The above works perfectly in chrome device simulator mode. However, if I disable the device simulator and resize the desktop to Mobile width and try the toggle, it is not working. But the viewport content property changes as per the toggle code.



Update:




  1. Responsive design works perfectly in Mobile devices (Say, when width < n Pixels); The desktop and the Mobile view is switchable using a toggle button using the above-mentioned code.

  2. Responsive design works perfectly in Desktop Browser (When width resized to < n Pixels); The Desktop and Mobile view is not switchable. This is the issue.







html css twitter-bootstrap-3 responsive-design toggle






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday

























asked Nov 21 at 23:28









Gugan

75012158




75012158






This question has an open bounty worth +50
reputation from Gugan ending in 4 days.


The current answers do not contain enough detail.








This question has an open bounty worth +50
reputation from Gugan ending in 4 days.


The current answers do not contain enough detail.














  • Did you tried with initial-scale=1.0? If you use Bootstrap, why you use two different layouts?
    – SilvioCro
    Nov 22 at 1:00












  • Did you try with .resize(). or try calling the same code within .resize().
    – vssadineni
    yesterday










  • Yes, I am calling the same code in resize().
    – Gugan
    yesterday


















  • Did you tried with initial-scale=1.0? If you use Bootstrap, why you use two different layouts?
    – SilvioCro
    Nov 22 at 1:00












  • Did you try with .resize(). or try calling the same code within .resize().
    – vssadineni
    yesterday










  • Yes, I am calling the same code in resize().
    – Gugan
    yesterday
















Did you tried with initial-scale=1.0? If you use Bootstrap, why you use two different layouts?
– SilvioCro
Nov 22 at 1:00






Did you tried with initial-scale=1.0? If you use Bootstrap, why you use two different layouts?
– SilvioCro
Nov 22 at 1:00














Did you try with .resize(). or try calling the same code within .resize().
– vssadineni
yesterday




Did you try with .resize(). or try calling the same code within .resize().
– vssadineni
yesterday












Yes, I am calling the same code in resize().
– Gugan
yesterday




Yes, I am calling the same code in resize().
– Gugan
yesterday












2 Answers
2






active

oldest

votes

















up vote
0
down vote



accepted










I tried the same code in different bootstrap layouts. The results are the same. There seems to be no issue with my code.



$('meta[name="viewport"]').prop('content', 'width=device-width, initial-scale=1.0'); // Toggle code for Mobile View


This is intended to work on Mobile devices or simulators. Not for desktop browsers.



Switching Mobile/Desktop views in the browser seems not an option.



Refer this answer: set viewport using meta viewport tag for desktop browsers






share|improve this answer




























    up vote
    -1
    down vote













    Try to use bootstrap media query breakpoints
    https://scotch.io/tutorials/default-sizes-for-twitter-bootstraps-media-queries






    share|improve this answer





















    • Sorry, I don't get it. Use this to do what?
      – Gugan
      yesterday











    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',
    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%2f53421872%2fhtml-switch-desktop-and-mobile-view-is-not-working-on-browser-resize%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote



    accepted










    I tried the same code in different bootstrap layouts. The results are the same. There seems to be no issue with my code.



    $('meta[name="viewport"]').prop('content', 'width=device-width, initial-scale=1.0'); // Toggle code for Mobile View


    This is intended to work on Mobile devices or simulators. Not for desktop browsers.



    Switching Mobile/Desktop views in the browser seems not an option.



    Refer this answer: set viewport using meta viewport tag for desktop browsers






    share|improve this answer

























      up vote
      0
      down vote



      accepted










      I tried the same code in different bootstrap layouts. The results are the same. There seems to be no issue with my code.



      $('meta[name="viewport"]').prop('content', 'width=device-width, initial-scale=1.0'); // Toggle code for Mobile View


      This is intended to work on Mobile devices or simulators. Not for desktop browsers.



      Switching Mobile/Desktop views in the browser seems not an option.



      Refer this answer: set viewport using meta viewport tag for desktop browsers






      share|improve this answer























        up vote
        0
        down vote



        accepted







        up vote
        0
        down vote



        accepted






        I tried the same code in different bootstrap layouts. The results are the same. There seems to be no issue with my code.



        $('meta[name="viewport"]').prop('content', 'width=device-width, initial-scale=1.0'); // Toggle code for Mobile View


        This is intended to work on Mobile devices or simulators. Not for desktop browsers.



        Switching Mobile/Desktop views in the browser seems not an option.



        Refer this answer: set viewport using meta viewport tag for desktop browsers






        share|improve this answer












        I tried the same code in different bootstrap layouts. The results are the same. There seems to be no issue with my code.



        $('meta[name="viewport"]').prop('content', 'width=device-width, initial-scale=1.0'); // Toggle code for Mobile View


        This is intended to work on Mobile devices or simulators. Not for desktop browsers.



        Switching Mobile/Desktop views in the browser seems not an option.



        Refer this answer: set viewport using meta viewport tag for desktop browsers







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered yesterday









        Gugan

        75012158




        75012158
























            up vote
            -1
            down vote













            Try to use bootstrap media query breakpoints
            https://scotch.io/tutorials/default-sizes-for-twitter-bootstraps-media-queries






            share|improve this answer





















            • Sorry, I don't get it. Use this to do what?
              – Gugan
              yesterday















            up vote
            -1
            down vote













            Try to use bootstrap media query breakpoints
            https://scotch.io/tutorials/default-sizes-for-twitter-bootstraps-media-queries






            share|improve this answer





















            • Sorry, I don't get it. Use this to do what?
              – Gugan
              yesterday













            up vote
            -1
            down vote










            up vote
            -1
            down vote









            Try to use bootstrap media query breakpoints
            https://scotch.io/tutorials/default-sizes-for-twitter-bootstraps-media-queries






            share|improve this answer












            Try to use bootstrap media query breakpoints
            https://scotch.io/tutorials/default-sizes-for-twitter-bootstraps-media-queries







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 2 days ago









            Ace

            325522




            325522












            • Sorry, I don't get it. Use this to do what?
              – Gugan
              yesterday


















            • Sorry, I don't get it. Use this to do what?
              – Gugan
              yesterday
















            Sorry, I don't get it. Use this to do what?
            – Gugan
            yesterday




            Sorry, I don't get it. Use this to do what?
            – Gugan
            yesterday


















             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421872%2fhtml-switch-desktop-and-mobile-view-is-not-working-on-browser-resize%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

            Catalogne

            Violoncelliste

            Héron pourpré