the electrohippie collective action tool development group, July 2006
The purpose of the Browser Alert tool is to facilitate the identification of a particular model of web browser by its "User Agent" identifier. Then, upon the identification of a particular browser, the user is offered the option of forwarding to a particular page where further information can be obtained.
the electrohippies action tool development group were charged with the problem of developing this client-side script as part of planning a campaign against the forthcoming Micro$oft Vista system[1]. Although our implementation is Micro$oft specific, this script could be used as a means to forward users to browser-specific pages on a web site if the confirm() dialog call were replaced with a window.location.href statement (see the "Variant B" option outlined later in this report).
All web browsers identify themselves with a string that identifies the model and the version of the browser. On the client-side, this string is held in the navigator object. The script tests this string against a list of (or just one) strings to find a match. If a match is found the script displays a confirm() dialog that gives the opportunity to cancel the alert or forward to another page to find out more information about the Browser Alert initiative.
The tool comes in three parts:
Finally, for the curious user, the Browser Alert code contains a second function called whatami(). This function reads the browser information and displays it within an alert() dialog. This function can be called via a link or a button.
The code of the pollid() function is shown below. To configure for a particular web site there are three key variables that you will have to configure:
Firstly, alert_text. This is the text of the alert displayed in the confirm() dialog that is thrown up when the function identifies a model/version of a particular browser. This can be any string, but it cannot contain quote (") characters (because the string is delimited by quotes). Although you can insert any message you like, you will have to experiment by insert line breaks (\n) in appropriate locations so that the message displays neatly within the confirm() dialog box.
Next, referral. This string contains the web address of the page that the script will redirect the user to. This link can be a literal or relative link for example:
Lastly, you have to set up a list of strings within the list array. Each string has the format:
In order to decide what to put in this string you will have to evaluate the content of the navigator.appName parameter for different browsers and then produce a string which will match the browser model/version that you required to trigger the alert/redirection (you can do this by calling the whatami() function from different browsers to view the content of the User Agent string). As we are only seeking to identify one type of browser any browser that identifies itself using the name "Microsoft" the script only has one element in the array, but potentially you could have a long list of string to identify different browsers, or different versions of the same browser. In order to check that the script works correctly with your configured list of browsers you should ideally try out using your page with all those browsers to confirm that the script identifies them correctly.
Note that the purpose of this script is to give the user the option of forwarding to another page. If you didn't do this then they could never actually read the page that you enclosed the Browser Alert tool within because they would always be forwarded to a different page. However, we have developed two variants to the head code (these are shown below). "Variant A" merely displays an alert() dialog which the user clicks to clear it will not forward them to another location. "Variant B" does not issue an alert dialog, but instead it immediately forwards the user to a different location.
// POLLID() -- browser ID test function
function pollid() {
// declare variables
var alert_text = "";
var ctr = 0;
var list = new Array();
var name = navigator.appName;
var ptr = 0;
var referral = "";
var retval = false;
// initialise variables
alert_text = "BROWSER ALERT!!\n\nYou appear to be using a browser" +
" based on proprietary software.\n\nThis could compromise" +
" your free access to the Internet at some time in the " +
"future\n\nTo find out why this is a problem click 'OK', " +
"otherwise click 'Cancel'.\n\n";
list[ 0] = "Microsoft";
referral = "browser_freedom_alert.html";
/* scan the list of strings for a match -- if a match is
found increment the counter */
for ( ptr = 0; ptr < list.length; ptr++) {
if ( name.indexOf( list[ptr]) > -1) {
ctr++;
}
}
/* if the counter is greater than zero ("match found")
call the confirm() dialog to display the alert message
and redirect the user (if desired) */
if ( ctr > 0) {
retval = confirm( alert_text);
if ( retval == true) {
window.location.href = referral;
}
}
}
"Variant A"
if ( ctr > 0) {
retval = alert( alert_text);
}
"Variant B"
if ( ctr > 0) {
window.location.href = referral;
}
|
Finally, to provides additional information for the page user, we have also provided the whatami() function. This simply reads the parameters of the navigator object and returns them to the user as a formatted text string within an alert() dialog.
// WHATAMI() -- browser ID information function
function whatami() {
// declare variables
var data = new Array();
var ptr = 0;
var str = "";
var text = new Array();
// initialise variables
data[ 0] = navigator.appName;
data[ 1] = navigator.appVersion;
data[ 2] = navigator.appCodeName;
data[ 3] = navigator.userAgent;
text[ 0] = "Your browser revealed the following identification:";
text[ 1] = "Browser name... ";
text[ 2] = "Version ID........ ";
text[ 3] = "Code name...... ";
text[ 4] = "User agent ID.. ";
/* composite report string */
for (ptr = 0; ptr < 5; ptr++) {
if (ptr == 0)
{
str = text[ 0] + "\n";
}
else
{
str = str + text[ ptr] + data[ ptr 1] + "\n";
}
}
/* display report string */
alert( str);
}
|
There are various options to implement the Browser Alert tool. To assist you we have produced a web page containing examples of how Browser Alert can be included within a web page. You can also download files containing the head and the body code of the tool[2]. Note that the examples web page has the filename extension ".txt" so that it can be viewed online you need to remove this extension to actually use the page with a browser. Likewise the head and body code JavaScript files have the ".txt" extension you don't have to remove the extension to link to the files, but for the sake of clarity it's a good idea to.
Firstly, you have to load the main Browser Alert "head code" (the code that goes in the <HEAD> section of the web page). You can do this in two ways:
Note that by loading the head code file as a link, you are loading both the pollid() and whatami() functions. If you manually insert the head code into the <HEAD> section of your page you must include the complete pollid() function, but you only need include the whatami() function if you wish to use it.
To use the pollid() function it must be called from the <BODY> of a page. The options are to call the function automatically, or give the user the choice by using a link or a button that must be clicked upon to call the the function.
For automatic calling you have to build-in a JavaScript call from the web page. Some browsers will allow you to call the function from the <BODY> tag using the ONLOAD event call as follows (but this isn't reliable in all browsers, so we don't recommend it!):
The simplest way to automatically call the pollid() function is with an in-line <SCRIPT> tag from within the <BODY> section of your web page. Again there are two methods to do this:
To call the pollid() function voluntarily you need either a hyperlink or a form/button combination:
If you wish to provide the user with the details of their browser's ID, you call the whatami() function in the same way:
or
So far the Browser Alert tool has only had limited evaluation live online. As we receive feedback on its performance in the future we may issue modifications to the code.
One early result is that the Opera browser (available as part of various Gnu/Linux distributions) will trigger an alert because its User Agent ID identifies it as a Microsoft browser (in fact, as the electrohippie collective don't use Windoze at all, this useful feature allows us to test our Micro$oft-specific browser tools off-line!). We don't see this as an issue as, in any case, there is an issue as to how "free" the Opera browser is.
In our view Browser Alert is a tool which, if creatively used by the advocates of free software, could help to highlight the issue of standards and digital rights management on the Internet. Rather than requiring those who are interested in free/open source software to browse the relevant sites, web pages wholly unrelated to free software could install the Browser Alert tool to direct Windoze users to pages that cover these issues. We hope that, as the launch of Micro$oft's new Vista operating system approaches, Browser Alert will be adopted by many web sites as part of a decentralised campaign against Micro$oft's hegemonic control on desktop computing, and the continued creep of "closed" standards on the Internet.
DJNZ
action tool development group,
the electrohippie collective,
July 2006
Notes
[1] See the electrohippies "No Bill Inside" campaign page http://www.fraw.org.uk/ehippies/no_bill_inside.shtml
[2] See the electrohippies Tools page http://www.fraw.org.uk/ehippies/tools.shtml