Home > Article > Web Front-end > How to judge chrome browser using javascript_javascript skills
Use userAgent to determine whether the string returned by userAgent contains "Chrome". The specific detection is done through the indexOf method.
About indexOf method:
The indexOf method returns an integer value indicating the starting position of the substring within the String object. That is, the position of the characters contained in the brackets of indexOf() in the string is returned, and counting starts from 0. If there are repeated characters, the first character shall prevail. If the substring is not found, -1 is returned.