我只想在移动应用程序中隐藏标题,但必须在所有移动浏览器中显示与桌面浏览器相同的标题。如何通过css媒体查询或java脚本识别移动应用程序,否则有没有选择找到移动应用程序? 你能帮我吗我可以隐藏html标题只能在移动应用程序上吗? 我试过下面的java脚本代码,但我没有得到结果
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
var isFirefox = typeof InstallTrigger !== 'undefined';
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
var isIE = /*@cc_on!@*/false || !!document.documentMode;
var isEdge = !isIE && !!window.StyleMedia;
var isChrome = !!window.chrome && !!window.chrome.webstore;
var isBlink = (isChrome || isOpera) && !!window.CSS;
var isMobile = {
Android: function () {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function () {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function () {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function () {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function () {
return navigator.userAgent.match(/IEMobile/i) || navigator.userAgent.match(/WPDesktop/i);
},
any: function () {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
var mobOpera = (navigator.userAgent.indexOf("Opera") || navigator.userAgent.indexOf('OPR')) != -1;
var mobChrome = navigator.userAgent.indexOf("Chrome") != -1;
var mobSafari = navigator.userAgent.indexOf("Safari") != -1;
var mobFirefox = navigator.userAgent.indexOf("Firefox") != -1;
var mobIe = (navigator.userAgent.indexOf("MSIE") != -1) || (!!document.documentMode == true);
var nua = navigator.userAgent;
var is_android = ((nua.indexOf('Mozilla/5.0') > -1 && nua.indexOf('Android ') > -1 && nua.indexOf('AppleWebKit') > -1) && !(nua.indexOf('Chrome') > -1));
if (isOpera || isFirefox || isSafari || isIE || isEdge || isChrome || isBlink) {
$(".navbar-fixed-top").css("display", "block");
}
else if (mobOpera || mobChrome || mobSafari || mobFirefox || mobIe) {
$(".navbar-fixed-top").css("display", "block");
}
else if(is_android || isMobile.any()){
$(".navbar-fixed-top").css("display", "block");
}
else
$(".navbar-fixed-top").css("display", "none");