简体   繁体   English

使用某些浏览器查看时加载网站的移动版本

[英]Load mobile version of website when viewing with certain browsers

Is it possible for the mobile version of my site to be loaded based on browser. 我的网站的移动版本是否可以基于浏览器加载。 Chrome doesn't respond well to certain effects I have on my site, and was wondering if I could get my simplified, mobile version to load. Chrome对我在网站上产生的某些效果反应不佳,并且想知道是否可以加载简化的移动版本。 Thanks in advance. 提前致谢。

You can use Window.matchMedia(media query): 您可以使用Window.matchMedia(media query):

if (window.matchMedia("(max-width: 500px)").matches) {
    /* The viewport is less than, or equal to, 500 pixels wide */
} else {
    /* The viewport is greater than 500 pixels wide */
}

https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM