“VIEW FULL SITE” mobile site option

前端 未结 5 1732
别跟我提以往
别跟我提以往 2020-12-15 01:41

So I\'m working on the mobile version of a site I\'m doing, and so far, I\'m pulling the mobile sites content from its main counterpart, the main site.

As I study s

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-15 02:19

    You can add a query string parameter to your website address such as ?fullsite=true and include the following in your if condition >

    var fullsite = getQueryString()["fullsite"];
    if (fullsite != "true" && (screen.height <= xyz || screen.width <= abc)) //now redirect
    

    You'll need the following function access query string. I took it from here > JavaScript query string

    function getQueryString() {
      var result = {}, queryString = location.search.substring(1),
          re = /([^&=]+)=([^&]*)/g, m;
    
      while (m = re.exec(queryString)) {
        result[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
      }
    
      return result;
    }
    

    And in the link you can have >

    Show me Full Site

    ===========

    Saying that please take a look at CSS Media Queries. It may require changing a bit of your design architecture but it's pretty useful.

提交回复
热议问题