如果是移动设备,如何不运行功能?

发布于 2024-08-29 17:19:22 字数 276 浏览 7 评论 0原文

我的网站上有一个模态弹出功能,但如果浏览器小于 480px,我不希望它运行。我发现,如果我放置一个 if 语句,例如:

if (window.innerWidth && window.innerWidth > 480) {

 run function()
}

那么它应该仅在浏览器的 innerWidth > 时运行480.然而它不起作用,我认为这是因为我在这个网站上有页面缩放。如果页面缩放已打开,任何人都可以帮助我使用条件语句吗?谢谢。

I have a modal pop up function on my website, but i don't want this to run if the browser is smaller than 480px. I have found that if I put an if statement such as:

if (window.innerWidth && window.innerWidth > 480) {

 run function()
}

Then it should run only if the browsers innerWidth is > 480. However its not working and I think its because I have page scaling on this website. Can any one help me with a conditional statement if page scaling is on? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

从﹋此江山别 2024-09-05 17:19:22

我已经想通了。

if (window.outerWidth && window.outerWidth > 480) {

}

I have figured it out.

if (window.outerWidth && window.outerWidth > 480) {

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文