In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces you the solution to the compatibility problem of JS script, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Here are a few tips for solving JS script compatibility. The first question we should consider about JS script compatibility should be whether the running platform supports client script. It is common practice to include the script body in a HTML comment.
A few tips for solving the compatibility of JS scripts
Where there is JS scripting compatibility, the solution is to use different features for different platforms or use alternative methods, which is the best policy; but there are times when we can't solve the problem with the above method, we can see if the problem is serious, if not, then we can ignore it.
1. Use HTML to comment out the script
One of the questions we should consider about JS script compatibility is whether the running platform supports client script. A common practice is to include the script body in a HTML comment:
Browsers that do not support JS scripts ignore the and tags and treat other code as a HTML comment, while browsers that support scripts comment one-line with "/ /".
two。 Characteristics, platform detection
When the feature we want to use is related to the platform, we have to test it first and then use it. There are two ways of detection: one is to directly detect whether the platform supports the feature, and the other is to test the platform type and then use the corresponding feature. The code is as follows:
3. Substitute? ignore? Stop it?
For places where there is JS script compatibility, the solution is to use different features or alternative methods for different platforms, this is the best policy; but there are times when we can't solve the problem with the above methods, we can see if the problem is serious, if not, then we can ignore it. For example, a feature is invalid on Netscape2, but now basically no one uses Netscape2, so we ignore it. If it can't be solved but the problem is serious, then we should stop running the script and tell the user exactly what happened!
This is the end of the solution to the compatibility problem of JS scripts. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.