PHP determines whether the alexa Toolbar is installed in the user's browser

Source: Internet
Author: User

As we all know, the alexa Toolbar is a commonly used third-party statistical tool for websites. We usually customize the alexa toolbar to allow users to install it. You can click the toolbar content to improve the ranking of the website in alexa. The alexa toolbar of Hebei News Network is shown in the following figure.

If we need to force user installation in some necessary php applications, this involves the judgment on whether the alexa Toolbar is installed or not. When a browser accesses a webpage, php can obtain User-Agent characters. When a browser with the Alexa Toolbar is used to request a webpage, the User-Agent character will contain more alexa marks. With this feature, you can determine whether your browser has installed the ALEXA toolbar. Use PHP's $ _ SERVER ['http _ USER_AGENT '] to obtain the UA string information of the browser.The following is the code for PHP to determine whether the alexa tool is installed in your browser:

The code is as follows: Copy code
If (! Preg_match ("# Toolbar # I", $ _ SERVER ['http _ USER_AGENT ']) {
Showmessage (L ('Alexa _ failure '), 'https: // www.111cn.net', 8000 );
            }
(Because the User-Agent characters in firefox and ie are different, Alexa Toolbar in firefox and My Toolbar in ie. Therefore, we only need to determine whether the recognition character contains a Toolbar)

Note: how to obtain the alexa toolbar information of IE9

According to the official Microsoft development blog, IE9 uses short User-Agent characters by default and does not append. NET or any other information generated by software or machines to UA strings. Therefore, if you want to obtain whether the IE9 user has installed the alexa toolbar, you must click"Compatibility View"(As shown in the following figure)

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.