我如何强制Safari启用我的网站JavaScript?

发布于 2025-01-19 17:52:58 字数 140 浏览 2 评论 0原文

最近,我收到了大学和朋友的反馈,即我的网站的某些功能在苹果设备上不起作用。通过一些研究,我发现Safari阻止了JavaScript。

我该如何强迫它?

更具体地说,需要JavaScript来在光模式和黑暗模式以及意大利语和英语之间切换。

Recently I've got feedbacks from collegues and friends that some features of a website of mine doesn't work on Apple devices. With some research, I found out that Safari blocks javascript.

How can I force it?

More specifically, javascript is needed to toggle between light mode and dark mode and italian and english.

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

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

发布评论

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

评论(2

七堇年 2025-01-26 17:52:58

“问题”出在客户端。有些浏览器会自行阻止 JS,而另一些浏览器则由于用户定义的设置(例如出于安全原因)而这样做。

你不能强制浏览器使用 JS。你可以做的是构建一个在禁用 JS 时起作用的后备。

在您的情况下,您可以在 URL 中使用 PHP-GET 变量设置亮/暗模式或语言,并在服务器端进行处理。

The "problem" is on the clients side. Some browsers block JS by themselves, others do this due to user-defined settings, e.g. for security reasons.

You cannot force a browser to use JS. What you can do instead is build a fallback that works when JS is disabled.

In your case you could set the light/dark mode or the language with a PHP-GET variable in the URL and process that on the server side.

听不够的曲调 2025-01-26 17:52:58

至少我解决了它:我使用了一个包来识别 userAgent (https://github.com/hisorange /browser-detect),然后我将代码转换为不再依赖 JS,仅依赖 safari。

希望这可以帮助别人!

(我仍在尝试找出如何标记此问题已解决)

At least I solved it: I used a package to recognize the userAgent (https://github.com/hisorange/browser-detect) and then I transform my code to no longer depend on JS, only on safari.

Hope that this can help somebody else!

(I'm still trying to figure out how to mark this has resolved)

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