passive revisou este gist 2 years ago. Ir para a revisão
1 file changed, 7 insertions
disable_js_on_mobile.js
| @@ -1,3 +1,4 @@ | |||
| 1 | + | // method 1 | |
| 1 | 2 | function isMobile() { | |
| 2 | 3 | return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); | |
| 3 | 4 | } | |
| @@ -6,3 +7,9 @@ if (!isMobile()) { | |||
| 6 | 7 | //place script you don't want to run on mobile here | |
| 7 | 8 | ||
| 8 | 9 | } | |
| 10 | + | ||
| 11 | + | ||
| 12 | + | // method 2 | |
| 13 | + | if (window.matchMedia('(min-width: 768px)').matches) { | |
| 14 | + | //place script you don't want to run on mobile here | |
| 15 | + | } | |
passive revisou este gist 2 years ago. Ir para a revisão
1 file changed, 8 insertions
disable_js_on_mobile.js(arquivo criado)
| @@ -0,0 +1,8 @@ | |||
| 1 | + | function isMobile() { | |
| 2 | + | return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); | |
| 3 | + | } | |
| 4 | + | ||
| 5 | + | if (!isMobile()) { | |
| 6 | + | //place script you don't want to run on mobile here | |
| 7 | + | ||
| 8 | + | } | |