473,782 Members | 2,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Favicon type detection - possible?

I'm very noobish when it comes to Javascript, in fact I wasn't intending to
use it at all, but I've got myself distracted by this "problem". I want to
use an animated gif as my favicon. This works fine in Firefox, but Opera
and IE6 ignore it. To get around this, I started off attempting a browser
detection script (I know!) which I cobbled together from a couple of others,
but this doesn't work (is it because I'm trying to do weird things within
the header?). If I want to go down that road I can do it in PHP anyway.

But I thought, there must surely be a more elegant way of doing this. Like

if (browsericonsup port = gif) then
use gif
else
use ico

Any comments would be gratefully received.

+e

P.S. - for anyone interested, this is my cobbled together browser detection
code; I know it doesn't do anything with the favicon, but I was just seeing
if it would actually detect browsers correctly. The first bit, which I got
from here: http://www.quirksmode.org/js/detect.html does pick out the
browser correctly (tested on Firefox, Opera and IE6) but when I attempt to
alert it falls straight through the code. If I add "alert(browserN ame);"
then it alerts with "undefined" in all three browsers. I appreciate this is
very noobish!

<HEAD>
<SCRIPT language="JavaS cript">
<!--
var BrowserDetect = {
init: function () {
this.browser = this.searchStri ng(this.dataBro wser) || "An unknown browser";
this.version = this.searchVers ion(navigator.u serAgent)
|| this.searchVers ion(navigator.a ppVersion)
|| "an unknown version";
this.OS = this.searchStri ng(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
for (var i=0;i<data.leng th;i++) {
var dataString = data[i].string;
var dataProp = data[i].prop;
this.versionSea rchString = data[i].versionSearch || data[i].identity;
if (dataString) {
if (dataString.ind exOf(data[i].subString) != -1)
return data[i].identity;
}
else if (dataProp)
return data[i].identity;
}
},
searchVersion: function (dataString) {
var index = dataString.inde xOf(this.versio nSearchString);
if (index == -1) return;
return
parseFloat(data String.substrin g(index+this.ve rsionSearchStri ng.length+1));
},
dataBrowser: [
{ string: navigator.userA gent,
subString: "OmniWeb",
versionSearch: "OmniWeb/",
identity: "OmniWeb"
},
{
string: navigator.vendo r,
subString: "Apple",
identity: "Safari"
},
{
prop: window.opera,
identity: "Opera"
},
{
string: navigator.vendo r,
subString: "iCab",
identity: "iCab"
},
{
string: navigator.vendo r,
subString: "KDE",
identity: "Konqueror"
},
{
string: navigator.userA gent,
subString: "Firefox",
identity: "Firefox"
},
{
string: navigator.vendo r,
subString: "Camino",
identity: "Camino"
},
{ // for newer Netscapes (6+)
string: navigator.userA gent,
subString: "Netscape",
identity: "Netscape"
},
{
string: navigator.userA gent,
subString: "MSIE",
identity: "Explorer",
versionSearch: "MSIE"
},
{
string: navigator.userA gent,
subString: "Gecko",
identity: "Mozilla",
versionSearch: "rv"
},
{ // for older Netscapes (4-)
string: navigator.userA gent,
subString: "Mozilla",
identity: "Netscape",
versionSearch: "Mozilla"
}
],
dataOS : [
{
string: navigator.platf orm,
subString: "Win",
identity: "Windows"
},
{
string: navigator.platf orm,
subString: "Mac",
identity: "Mac"
},
{
string: navigator.platf orm,
subString: "Linux",
identity: "Linux"
}
]
};
BrowserDetect.i nit;

//bit nicked from http://www.quirksmode.org/js/detect.html above
//bit cobbled together by me below

var browserName = BrowserDetect.b rowser;
if (browserName==" Netscape")
{
alert("Hi Netscape User!");
}
else
{
if (browserName==" Explorer")
{
alert("Hi, Explorer User!");
}
else
{
if (browserName==" Firefox")
{
alert("Hi, Firefox User!");
}
else
{
if (operaName=="Op era")
{
alert("Hi, Opera User!");
}
else
{
alert("What ARE you browsing with here?");
}
}
}
}
//-->
</SCRIPT>
</HEAD>
Sep 20 '06 #1
5 1880
The Eclectic Electric wrote:
I'm very noobish when it comes to Javascript, in fact I wasn't intending to
use it at all, but I've got myself distracted by this "problem". I want to
use an animated gif as my favicon. This works fine in Firefox, but Opera
and IE6 ignore it. ...
<snip>
>
But I thought, there must surely be a more elegant way of doing this. Like

if (browsericonsup port = gif) then
use gif
else
use ico

Any comments would be gratefully received.
Wouldn't the HTTP accept header for the request from the browser for
the icon be expected to state the accepted content types? Why not
detect that with you PHP and serve content accordingly?
P.S. - for anyone interested, this is my cobbled together browser
detection code; I know it doesn't do anything with the favicon, but
I was just seeing if it would actually detect browsers correctly....
<snip>

It does not.

Richard.

Sep 20 '06 #2
"Richard Cornford" <Ri*****@litote s.demon.co.ukwr ote in message
news:11******** *************@b 28g2000cwb.goog legroups.com...
The Eclectic Electric wrote:
>I'm very noobish when it comes to Javascript, in fact I wasn't intending
to
use it at all, but I've got myself distracted by this "problem". I want
to
use an animated gif as my favicon. This works fine in Firefox, but Opera
and IE6 ignore it. ...
<snip>
>>
But I thought, there must surely be a more elegant way of doing this.
Like

if (browsericonsup port = gif) then
use gif
else
use ico

Any comments would be gratefully received.

Wouldn't the HTTP accept header for the request from the browser for
the icon be expected to state the accepted content types? Why not
detect that with you PHP and serve content accordingly?
Very good idea. Unfortunately I can't see a way to isolate the specific
request for the icon.

+e
Sep 21 '06 #3
The Eclectic Electric wrote:
Richard Cornford wrote:
>The Eclectic Electric wrote:
>>I'm very noobish when it comes to Javascript, in fact I wasn't
intending to use it at all, but I've got myself distracted by
this "problem". I want to use an animated gif as my favicon.
This works fine in Firefox, but Opera and IE6 ignore it. ...
<snip>
>Wouldn't the HTTP accept header for the request from the
browser for the icon be expected to state the accepted
content types? Why not detect that with you PHP and
serve content accordingly?
Very good idea. Unfortunately I can't see a way to isolate
the specific request for the icon.
If PHP is worth anything as a server side scripting language that task
is trivial. Try asking in a PHP group.

Richard.

Sep 21 '06 #4
"Richard Cornford" <Ri*****@litote s.demon.co.ukwr ote in message
news:11******** *************@e 3g2000cwe.googl egroups.com...
The Eclectic Electric wrote:
>Richard Cornford wrote:
>>The Eclectic Electric wrote:
I'm very noobish when it comes to Javascript, in fact I wasn't
intending to use it at all, but I've got myself distracted by
this "problem". I want to use an animated gif as my favicon.
This works fine in Firefox, but Opera and IE6 ignore it. ...
<snip>
>>Wouldn't the HTTP accept header for the request from the
browser for the icon be expected to state the accepted
content types? Why not detect that with you PHP and
serve content accordingly?
Very good idea. Unfortunately I can't see a way to isolate
the specific request for the icon.

If PHP is worth anything as a server side scripting language that task
is trivial. Try asking in a PHP group.

Richard.
I have to confess I'm out of my depth when it comes to the technicalities of
these things, but wouldn't the request for <LINK REL="icon" ... /go to the
web server and not get routed through the PHP engine? Once I've served the
original page, isn't the PHP engine quiet until another PHP page is
requested?

+e
Sep 21 '06 #5
The Eclectic Electric wrote:
Richard Cornford wrote:
>The Eclectic Electric wrote:
>>Richard Cornford wrote:
<snip>
>>Very good idea. Unfortunately I can't see a way to isolate
the specific request for the icon.

If PHP is worth anything as a server side scripting language that task
is trivial. Try asking in a PHP group.

I have to confess I'm out of my depth when it comes to the technicalities
of these things, but wouldn't the request for <LINK REL="icon" ... />
go to the web server and not get routed through the PHP engine?
First, it does no make sense to ask PHP questions in a javascript
newsgroup.

If the HREF referred to in the LINK element is the URL of a PHP
resource it will receive the request and should be able to examine the
HTTP header. Otherwise the HTTP server can map any incoming URL to any
resource, including PHP scripts.
Once I've served the original page, isn't the PHP engine quiet until
another PHP page is requested?
Ask a PHP group (humbly).

Richard.

Sep 21 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
14169
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip Smarty-2.6.7.tar.gz on a system running WindowsXP SP2. Apache and PHP tested out fine. After adding Smarty, I ran the following http://localhost/testphp.php
7
5025
by: Bart | last post by:
Hi there, If I use frames, should a reference to the favicon.ico (like: <link rel="shortcut icon" href="pictures/favicon.ico" type="image/x-icon">) be placed on _every page_, or is one reference in the index.htm (top-frame) enough. I'm asking this question because I had a reference in my top-frame only, wich seemed to work OK (the favicon showd in the adress-bar in all frames), but all of a sudden the favicon won't show anymore in the
1
1652
by: Patrick Olurotimi Ige | last post by:
I have an icon called favicon.ico that i created for a website and it WORKS but u have to first bookmark the page before u see the ICON in the URL instead of the IE icon! <link rel="shortcut icon" href="favicon.ico"> But is it possible for users to see it without first Adding the page to the favorites!!... Any ideas..
4
2959
by: Chameleon | last post by:
the extension of favicon MUST BE ico? what if I use a 16x16 favicon.png?
15
2914
by: BT | last post by:
I'm have a problem showing a favicon in ver 1.7.10. It shows up correctly in the address bar, but is missing from the tab. I've tried each of these HTML 'statements' to add the favicon to the page, but no luck: <link rel="shortcut icon" href="/favicon.ico" > <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" /> FWIW, it seems to render OK in IE v6.0. I haven't tried it in FFox 2.0 yet, but I'll need it to work there...
2
4211
by: alice | last post by:
I'm trying to create a favicon which I've done before, and it just won't show up. I've even saved the file as a gif and entered the URL of where the file is according to my FTP program, and I get a File Cannot Be Found error. I've copied the pixels from the file and pasted them into a favicon that is working and showing up, renamed it by just adding a number to the end, and still it won't show up, either as an .ico or a .gif. So I've...
7
6268
by: =?Utf-8?B?VmFuY291dmVyTWlrZQ==?= | last post by:
Hi there, I am using asp.net 2.0 and C# to develop my website. I would like to put a favicon to my website, so I put the following code in the <headsection right after <titletag in a master page: <link rel="Shortcut Icon" href="/favicon.ico" type="image/x-icon"/> All my pages are reference to this master page. My icon file in the site root and it's a windows icon format. The problem is that it's not showing in
4
3053
by: mistral | last post by:
Does it possible change favicon icon depending on browser type: display favicon.ico for Internet Explorer browsers, and favicon.gif for the rest browsers? Problem is that ugly MSIE can display only .ICO favicons, whereas other browsers support any favicon type - gif, png, jpg. Since gif favicons has much better quality than ico file, I'm wondering does it possible sort browsers with javascript and show appropriate favicon type for...
19
678
by: Moon | last post by:
Bergamot wrote in <6i534eFolqk5U1@mid.individual.net>: Done! http://moon.descentforum.net/creep/ with 2 issues though: I liked the funtionality of target="_blank", so people that are unaware of
0
9641
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.