简体   繁体   English

如何强制 safari 启用我的网站 javascript?

[英]How can I force safari to enable my website 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.通过一些研究,我发现 Safari 块 javascript。

How can I force it?我怎么能强迫它?

More specifically, javascript is needed to toggle between light mode and dark mode and italian and english.更具体地说,需要 javascript 才能在浅色模式和深色模式以及意大利语和英语之间切换。

The "problem" is on the clients side. “问题”在客户端。 Some browsers block JS by themselves, others do this due to user-defined settings, eg for security reasons.一些浏览器自己阻止 JS,其他浏览器由于用户定义的设置而这样做,例如出于安全原因。

You cannot force a browser to use JS.您不能强制浏览器使用 JS。 What you can do instead is build a fallback that works when JS is disabled.你可以做的是构建一个在 JS 被禁用时工作的后备。

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

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.至少我解决了它:我使用 package 来识别 userAgent ( https://github.com/hisorange/browser-detect ) 然后我将我的代码转换为不再依赖 JS,仅依赖 safari。

Hope that this can help somebody else!希望这可以帮助别人!

(I'm still trying to figure out how to mark this has resolved) (我仍在尝试弄清楚如何将其标记为已解决)

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

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