我如何强制Safari启用我的网站JavaScript?
最近,我收到了大学和朋友的反馈,即我的网站的某些功能在苹果设备上不起作用。通过一些研究,我发现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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
“问题”出在客户端。有些浏览器会自行阻止 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.
至少我解决了它:我使用了一个包来识别 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)