Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 移动设备横向模式显示不支持的消息_Jquery_Html_Responsive Design - Fatal编程技术网

Jquery 移动设备横向模式显示不支持的消息

Jquery 移动设备横向模式显示不支持的消息,jquery,html,responsive-design,Jquery,Html,Responsive Design,我正在创建一个响应性网站,它在浏览器上是响应性的,但当它在移动横向模式下打开时,不支持模式信息应该显示出来,我用下面的代码实现了这一点,但它也被应用到了桌面上 // On Orientation Change $(window).resize( function(){ var h = $(window).height(); var w = $(window).width(); if ( w < 600) { if(w > h) { // Small Screen La

我正在创建一个响应性网站,它在浏览器上是响应性的,但当它在移动横向模式下打开时,不支持模式信息应该显示出来,我用下面的代码实现了这一点,但它也被应用到了桌面上

 // On Orientation Change
 $(window).resize( function(){
 var h = $(window).height();
 var w = $(window).width();

 if ( w < 600) {
 if(w > h) {
 // Small Screen Landscape Rules
 $('#about').css('display','none');
 $('.landscapemsg').css('display','block');
 }else{
 // Small Screen Portrait Rules
 $('#about').css('display','block');
  $('.landscapemsg').css('display','none');
 }
 // All Small Screen Rules
 }

 });
 }else{
    // Not a mobile device
     $('#about').css('display','block');
 }

请帮助我仅在移动设备上应用此功能

我认为您必须首先检测您的设备, 也许这段javascript代码可以帮助您

var device =  navigator.userAgent;
    var patern = 'Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|avantgo|blazer|compal|elaine|fennec|hiptop|iemobile';
    var found = device.match( patern );
    if (found != null) {
        // this is mobile device
    }
试试这个:

在.js文件中:

注: document.URL.indexOf'http://'===-1&&document.URL.indexOf'https://'==-1


对于浏览器,此代码失败

你读过CSS媒体查询吗?从那里开始。
var appCheck = document.URL.indexOf( 'http://' ) === -1 && document.URL.indexOf( 'https://' ) === -1;

if(appCheck)
{
//your mobile content will goes here. 
}