简体   繁体   English

如果在移动设备上查看,应该如何首先加载移动内容?

[英]How Should I load my mobile content first if viewed on mobile?

I have a page which renders well in desktop,whose markup is totally different from mobile's markup,as design is different on both. 我有一个页面可以很好地呈现在桌面上,其标记与移动设备的标记完全不同,因为两者的设计都不同。

I add extra <div> in my existing desktop markup. 我在现有的桌面标记中添加了额外的<div>

I use media-queries for toggling from desktop to mobile,by hiding mobile content if viewed in desktop(width > 1024) and vice-versa. 我使用媒体查询从桌面切换到移动设备,方法是隐藏移动设备内容(如果在桌面设备上查看(宽度> 1024),反之亦然)。

I also use two different meta tags for mobile and ipad. 我还为移动设备和ipad使用了两个不同的meta标签。

For mobile: for removing pinch effect(zoom in/out) 对于手机:用于消除捏效果(放大/缩小)

For ipad: for allowing pinch effect(zoom in/out) 对于ipad:允许捏效果(放大/缩小)

I add this meta tags through javascript which adds meta for mobile if it is mobile and meta for ipad if tablet 我通过javascript添加了此meta标签,如果是移动设备,则添加了移动设备的元数据,如果是平板电脑,则添加了ipad的元数据

Now on when page viewed on mobile,desktop version loads for few seconds and after that mobile version is visible. 现在,当在移动设备上查看页面时,桌面版本会加载几秒钟,并且在该移动版本可见之后。

Is it possible that i should be able to view my mobile version first, or when viewed on mobile just hide the desktop version?? 我是否应该能够首先查看我的移动版本,或者在移动设备上查看时仅隐藏桌面版本?

Here is My javascript code to toggle meta: 这是我的JavaScript代码来切换meta:

var browserdetect = function() {

    var ismobile = (/iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile|ipad|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase()));

    var istablet = (/ipad|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase()));

    var metaiphone = '<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0 maximum-scale=1.0, user-scalable=no">';

    var metaipad = '<meta name="viewport" content="width=1300">';

    if(ismobile) {
        if(!istablet) {
            if($('body').hasClass('responsive-page')){
                $('head').append(metaiphone);
            }               
        } else {
            $('head').append(metaipad);
            // console.log("tab");    
        }
    }
}

You have gone all wrong about this. 您对此事完全错了。 You should serve your mobile clients only the mobile html&css if it's totally different than the desktop version. 如果移动html&css与桌面版本完全不同,则应仅为移动客户端提供服务。 You should detect the client on the server and decide there which html&css to send them (or redirect mobile clients to a different domain that has a mobile version). 您应该在服务器上检测到客户端,然后决定向其发送哪些html&css(或将移动客户端重定向到具有移动版本的其他域)。

The point of media queries is to modify the existing html you have to work on different devices. 媒体查询的重点是修改必须在不同设备上工作的现有html。 You should look at this article for a quick overview: http://learn.shayhowe.com/advanced-html-css/responsive-web-design 您应该查看这篇文章以获得快速概述: http : //learn.shayhowe.com/advanced-html-css/sensitive-web-design

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 首次点击时如何更改我的jquery脚本以动画移动菜单? - how should i change my jquery script to animate mobile menu when first clicked? 如果在移动设备上查看脚本,如何禁用或隐藏脚本在我的网站上运行? - How can I disable or hide a script from running on my site if being viewed on a mobile device? 如果在移动设备上查看,则显示弹出窗口 - Popup to display if viewed on mobile 我应该如何着手开发手机游戏? - How should I proceed for develop mobile games? 网站无法在手机上加载内容 - Website does not load content on mobile 如何创建仅在从移动设备查看网站时才有效的手风琴盒? - How do I create an accordion box that only works if the site is being viewed from mobile? 如何编写一个 javascript web 应用程序在移动设备 safari 上查看时不会旋转? - How can I write a javascript web app that doesn't rotate when viewed on mobile safari? 在移动设备上查看时,布局变形 - Layout distorted when viewed on mobile 如何检测 React 应用程序是否真的在移动菜单操作上被查看 - How to detect if the React app is actually being viewed on mobile menu actions ReactJS:如何确定应用程序是在移动浏览器还是桌面浏览器上查看 - ReactJS: How to determine if the application is being viewed on mobile or desktop browser
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM