简体   繁体   中英

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.

How can I force it?

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

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.

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.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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