Answer the question
In order to leave comments, you need to log in
How to disable the script for mobile phones?
how to disable script display on mobile devices
Answer the question
In order to leave comments, you need to log in
Embed in html, this code include the script.js file on devices with a resolution of more than 990px (replace at your discretion)
<script type="text/javascript">
{
if (screen.width > 990) document.write ('<script type="text/javascript" src="script.js" ></script>');
}
</script>
add this module to your project:
const appleDevice = /iP(hone|od|ad)/;
const applePhone = /iPhone/i;
const appleIPod = /iPod/i;
const appleTablet = /iPad/i;
const androidPhone = /(?=.*\bAndroid\b)(?=.*\bMobile\b)/i;
const androidTablet = /Android/i;
const windowsPhone = /Windows Phone/i;
const windowsTablet = /(?=.*\bWindows\b)(?=.*\bARM\b)/i;
const otherBlackberry = /BlackBerry/i;
const otherOpera = /Opera Mini/i;
const otherFirefox = /(?=.*\bFirefox\b)(?=.*\bMobile\b)/i;
const sevenInch = /(?:Nexus 7|BNTV250|Kindle Fire|Silk|GT-P1000)/i;
function match(regex, target = navigator.userAgent) {
return regex.test(target);
}
export const isAppleDevice = match(applePhone) || match(appleIPod) || match(appleTablet) || match(appleDevice, navigator.platform);
export const isAndroidDevice = match(androidPhone) || match(androidTablet);
export const isWindowsDevice = match(windowsPhone) || match(windowsTablet);
export const isOtherDevice = match(otherBlackberry) || match(otherOpera) || match(otherFirefox);
export const isSevenInch = match(sevenInch);
export const isMobileDevice = isAppleDevice || isAndroidDevice || isWindowsDevice || isOtherDevice || isSevenInch;
export const isEmulator = isMobileDevice && !isWindowsDevice && (match(/Mac/, navigator.platform) || match(/Win32/, navigator.platform));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question