Donavan
Donavan

Reputation: 23

Permanently changing the UserAgent string in Firefox 4

Here is the deal. I have created some HTML/Javacript dashboards that will be displayed on big screen displays. The displays are powered by thin clients running WinXP and Firefox 4. There will also be a desktop version as well. I would like to use one url (dashboard.php) and then redirect to the appropriate page. I need to be able to differentiate between the big screen displays and someone using Firefox from the desktop. My thought was to permanently change the UserAgent string on the big screen deployments and use browser sniffing to determine which version to forward the user too. The problem is, it appears that FF4 has removed the ability to change the UA string permanently. Anyone have any ideas on how I could do this or an idea on how I can otherwise differentiate between big screens and a desktop user.

Upvotes: 1

Views: 573

Answers (4)

Boris Zbarsky
Boris Zbarsky

Reputation: 35064

You can set the UA string just fine in Firefox 4. The general.useragent.override preference will let you set it to whatever you want.

What was removed was a way to modify parts of the UA string without overriding the whole thing.

Upvotes: 0

webbiedave
webbiedave

Reputation: 48897

If IP address detection is not an option, you could simply set a cookie for the big screen machines.

You can do this by creating a special URL, e.g., /bigscreen which will set the cookie with an expiration date far into the future. Then in your script, simply check for the existence of that cookie.

Using a cookie means that you don't have to worry about continuing to append query strings to subsequent URLs.

Edit: You could even manually place the cookie in Firefox if you wish to avoid visiting a special URL. There are add-ons to facilitate that.

Upvotes: 0

Dejan Marjanović
Dejan Marjanović

Reputation: 19380

Javascript

if((screen.width >= 1024) && (screen.height >=768))
{
    window.location= '?big=1';
}

PHP

if($_GET['big'] == 1){
    setcookie('big', 1, 0);
}

Then just read cookie, and that's it...

Upvotes: 0

Jonathan Kuhn
Jonathan Kuhn

Reputation: 15301

What about using the IP address of the computers displaying on the big screens? Especially if the big displays are on an internal network, assign them a static IP address and use that to identify the computers. Other than that, just pass a get string saying ?view=bigDisplay or similar. You can simply put in your code

$bigDisplay = (isset($_GET['view'])&&$_GET['view']=='bigDisplay');

then you would have a boolean of whether to display the bigDisplay code.

Edit: also, just googled and found this: http://support.mozilla.com/en-US/questions/806795

Upvotes: 1

Related Questions