This article will introduce you to PHP to determine whether the user's browser has the Alexa toolbar installed. The principle is very simple. We only need to identify the characters with the user's User-Agent, and then judge to know whether the user has the Alexa toolbar installed. .
As we all know, the Alexa toolbar is a commonly used third-party statistical tool for websites. Usually we customize the Alexa toolbar for users to install it, and improve the website’s ranking in Alexa through users’ clicks on the toolbar content. As shown in the picture below, the Alexa toolbar of Hebei News Network.
If we need to force users to install some necessary PHP applications, this involves judging whether the Alexa toolbar is installed or not. When the browser accesses a web page, php can obtain the user's User-Agent identification character. When using a browser equipped with Alexa Toolbar to request a web page, the Alexa tag will appear in the User-Agent identification characters. You can use this feature to determine whether the user's browser has the ALEXA toolbar installed. Obtain the browser's UA string information through PHP's $_SERVER['HTTP_USER_AGENT']. The following is PHP code to determine whether the user's browser has the Alexa toolbar installed:
The code is as follows
|
Copy code
if(!preg_match("#Toolbar#i", $_SERVER['HTTP_USER_AGENT'])){ | Note: How to obtain Alexa toolbar information in IE9showmessage(L('alexa_failure'), 'https://www.bKjia.c0m',8000); } ( Since the User-Agent identification characters in firefox and IE browsers are different, it is Alexa Toolbar in firefox and My Toolbar in IE. So when we judge, we only need to judge the identification characters. It doesn’t matter whether Toolbar is included) |
Microsoft’s official development blog stated that IE9 uses shorter User-Agent identification characters by default and no longer appends .NET and any other information generated by software or machines to the UA string. So if we want to get whether the IE9 user has installed the Alexa toolbar, we must let the user click "
www.bkjia.com