仅允许网站的桌面版本 [英] allow only desktop versions of a website

查看:81
本文介绍了仅允许网站的桌面版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在一个网站上工作,问题是它消耗了一些带宽,因此无法在手机上正常打开。因此,截至目前,我不希望我的网站可供移动平台上的任何人查看。也许如果有人试图打开,我可以向他显示一条消息,例如正在进行的工作。请尽快回来!



简而言之,我只希望我的网站只能在桌面和笔记本电脑上看到!请建议如何在移动平台上屏蔽它,或者显示即将推出。页面。



任何帮助都将受到高度赞赏。

Hi, i am currently working on a website where the problem is it's a bit bandwidth-consuming, so it doesn't open properly on mobiles. So, as of the moment, i don't want my website to be viewable to anyone on mobile platforms. Maybe if someone tries to open, i can show him a message like "Work in progress. Please come back soon!".

In short, i just want my website to be seen only on desktop and laptops! Please suggest how to block it on mobile platforms or instead display a "coming soon" page.

Any help will be highly appreciated.

推荐答案

首先,全部避开它手段。尝试在小屏幕上显示至少一些东西。尝试接受优雅降级优雅降级的想法 https://en.wikipedia.org/wiki/Elegant_degradation [ ^ ]。



但我明白,有时你不能立刻做很多好事。在这种情况下,让我们正确地制定问题。此刻,你做得不对。不在移动平台上显示整页的原因是什么?带宽不够?几乎不。试想一下:如果这个问题确实存在,它也可以出现在桌面上;一些桌面可以使用较慢的互联网连接,甚至可以通过移动设备提供的ad-hoc网络获得它。您想要检测移动设备,这将是一个很大的失误。整个想法都错了。



还有什么?最明显的是屏幕的像素大小,同时,这是显示更多内容的最明显的障碍。更准确地说,只有窗口区域的像素大小才是重要的。用户是否将其大小调整为太小,如果设备是桌面设备有什么区别?这很容易被发现。使用属性 window.innerHeight window.innerWidth

First and foremost, avoid it by all means. Try to show on the small screen at least something. Try to embrace the ideas of elegant degradation and graceful degradation: https://en.wikipedia.org/wiki/Elegant_degradation[^].

But I do understand that sometimes you cannot do a lot of too good job at once. In this case, let's properly formulate the problem. At this moment, you are not doing it right. What is the reason of not showing the full page on a mobile platform? Not enough bandwidth? Hardly. Just think about it: if this problem really exists, it can appear on the desktop as well; some desktops can use slower internet connection, they can even get it via the ad-hoc network served by a mobile device. That would be a great miss with your idea of detecting the mobile device. The whole idea is wrong.

What else? Most apparent thing is the pixel size of the screen, and, at the same time, this is the most apparent obstacle for showing more content. More exactly, only the pixel size of the windows area is important. Is the user resize it to a too small size, what's the difference if the device is desktop or not? And this is easy to detect. Use the properties window.innerHeight and window.innerWidth:
if (thereIsEnoughRoom(window.innerWidth, window.innerHeight);
   showItAll();
else
   showSorryComingSoon();



不合逻辑吗?



-SA


您可以使用Javascript检查设备,并可以相应地显示消息。

You can check device using Javascript and can accordingly display message.
var isMobile = false; //initiate as false
// device detection
if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) 
    || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4))) isMobile = true;





然后你可以显示一条消息并重定向到其他一些页面。

类似于 -



then you can show a message and redirect to some other page may be.
Something like-

if(ismobile==false)
{
   alert("comming soon");
   window.location="http://www.mywebsite.com";
}





参考: http://stackoverflow.com/questions/3514784/what-is-the-best-way-to-detect-a-移动设备在jquery [ ^ ]



希望,它有帮助:)



Reference: http://stackoverflow.com/questions/3514784/what-is-the-best-way-to-detect-a-mobile-device-in-jquery[^]

Hope, it helps :)


这篇关于仅允许网站的桌面版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆