I will give 20 frih$ to the person who can find me a code that will ask non-FireFox users to download FireFox when they visit my site.
It shouldn't be that hard, and it probably has been done, but I just don't have time to find it.
which one?
A javascript or PHP (or PHP's alternative)?
| Code: |
<HEAD>
<style type="text/css">
div#fenetre {
display:none;
position: absolute;
top: 200px;
left: 100px;
width: 340px;
border: 1px solid #CCC;
background: #F8F8F8;
z-index: 1;
font-family: Arial, Helvetica, sans-serif;
text-align:left;
}
div#fenetre h1 {
padding-left:15px;
font-size:14px;
font-family: Verdana, Arial, Helvetica, sans-serif;
color:#000;
text-align:left;
}
div#fenetre p {
padding-left:5px;
padding-right:5px;
font-size:12px;
}
div#fenetre div#fermer{
margin-top:10px;
font-size:12px;
text-align:left;
cursor: pointer;
background-color:#999;
width:100px;
text-align:center;
padding:4px;
border: 1px solid #2F2F2F;
}
div#fenetre div#telecharger {
background-color:#CCC;
}
div#fenetre div#titre {
padding:3px 0px 3px 5px;
background-color:#555;
border-bottom:2px solid #CCC;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
color:#FFF;
}
</style>
<script language="javascript" type="text/javascript">
var Navigateur = navigator.appName;
if(Navigateur == "Microsoft Internet Explorer"){
function fenetre(){
var fenetre = document.getElementById('fenetre');
if(fenetre){
fenetre.style.display = 'block';
};
}
window.onload = fenetre;
}
</script>
</HEAD>
<BODY>
<div id="fenetre">
<div id="titre">Détection de votre navigateur</div>
<h1>You are using INTERNET EXPLORER</h1>
<p>Please download Firefox ... blablablabla
</p>
<div style="float:left">
<script type="text/javascript"><!--
google_ad_client = "pub-8070064417713294";
google_ad_width = 110;
google_ad_height = 32;
google_ad_format = "110x32_as_rimg";
google_cpa_choice = "CAAQm4X7zwEaCLiCaAp7VchNKM2JwXU";
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div><p>Blablabla </p>
<div id="fermer">Close</div>
</div>
</BODY> |
Sorrry, an error had occured..
It's the right code :
| Code: |
<head>
<!--detection navigateur !-->
<script language="javascript" type="text/javascript">
var Navigateur = navigator.appName; if(Navigateur == "Microsoft Internet Explorer")
function fenetre()
{
var fenetre = document.getElementById('fenetre');
if (fenetre) {fenetre.style.display = 'block';};
if (fenetre) {fenetre.onclick = function() {this.style.display = 'none';};};
}
window.onload = fenetre;
</script>
<!--detection navigateur fin!-->
<!--Style CSS !-->
<style type="text/css">
div#fenetre { display:none; position: absolute; top: 200px; left: 100px; width: 340px; border: 1px solid #CCC; background: #F8F8F8; z-index: 1; font-family: Arial, Helvetica, sans-serif; text-align:left; }
div#fenetre h1 { padding-left:15px; font-size:14px; font-family: Verdana, Arial, Helvetica, sans-serif; color:#000; text-align:left; }
div#fenetre p { padding-left:5px; padding-right:5px; font-size:12px; }
div#fenetre div#fermer{ margin-top:10px; font-size:12px; text-align:left; cursor: pointer; background-color:#999; width:100px; text-align:center; padding:4px; border: 1px solid #2F2F2F; }
div#fenetre div#telecharger { background-color:#CCC; }
div#fenetre div#titre { padding:3px 0px 3px 5px; background-color:#555; border-bottom:2px solid #CCC; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; color:#FFF; }
</style>
<!--Style CSS fin!-->
</head>
<body>
<!--Message !-->
<div id="fenetre">
<div id="titre">Your navigator</div>
<h1>You are using Internet Explorer</h1>
<p>Download Firefox... Blabla blablal blabla
</p>
<div style="float:left">
<script type="text/javascript"><!--
google_ad_client = "pub-3984054005420766";
google_ad_width = 180;
google_ad_height = 60;
google_ad_format = "180x60_as_rimg";
google_cpa_choice = "CAAQv4j7zwEaCFfHfwD69JBzKPe493M";
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<p>Your TEXT....
</p>
<div id="fermer">
<a herf="fermer">Close</a> </div>
</div>
<!--Message fin!-->
</body> |
Thanks, but I am looking for a small script that I can add to a part of my site that would not need its own CSS, as I only need a small message.
<script language="javascript" type="text/javascript">
var Nav = navigator.appName;
if(Nav == "Microsoft Internet Explorer")
alert("Please download firefox");
</script>
Try above
| hunnyhiteshseth wrote: |
<script language="javascript" type="text/javascript">
var Nav = navigator.appName;
if(Nav == "Microsoft Internet Explorer")
alert("Please download firefox");
</script>
Try above |
Thanks, it's great, but do you know how to edit it so that it shows up for all browsers besides FireFox?
| Ratmaster wrote: |
| hunnyhiteshseth wrote: | <script language="javascript" type="text/javascript">
var Nav = navigator.appName;
if(Nav == "Microsoft Internet Explorer")
alert("Please download firefox");
</script>
Try above |
Thanks, it's great, but do you know how to edit it so that it shows up for all browsers besides FireFox? |
That code will show up only if the browser is IE, not anything else, if you want it so it won't if it's Firefox, use this:
| Code: |
<script language="javascript" type="text/javascript">
var Nav = navigator.appName;
if(Nav != "Netscape")
alert("Please download Firefox");
</script> |
I didn't test that code, but it should work alright.
Also not that if you want to warn them to update if there browser is too old, you can do this:
| Code: |
<script language="javascript" type="text/javascript">
var Nav = navigator.appName;
var Ver = navigator.appVersion;
if(Nav != "Netscape" || Ver < 4)
alert("Please download Firefox");
</script> |
You could seperate it like this, so if it's old, one message will output, and if it's not Firefox, another will output:
| Code: |
<script language="javascript" type="text/javascript">
var Nav = navigator.appName;
var Ver = navigator.appVersion;
if(Nav != "Netscape")
alert("Please download Firefox");
else if (Nav == "Netscape" && Ver < 4)
alert("It's time to update Firefox!");
</script> |
Please note that in JavaScript, the Firefox browser is detected as Netscape, as it's built on that engine.
Would it work if I use:
| Code: |
<script language="javascript" type="text/javascript">
var Nav = navigator.appName;
if(Nav == "Mozilla Firefox"){
}
else {
alert("Please download firefox");
}
</script> |
I just make it so that if it is anything else than Firefox, it will show the message?
No it won't, as the Firefox appName comes back as Netscape, if you want it really reliable, you can use this:
| Code: |
String userAgent = request.getHeader( "User-Agent" );
boolean isFirefox = ( userAgent != null && userAgent.indexOf( "Firefox/" ) != -1 );
response.setHeader( "Vary", "User-Agent" );
if(!isFirefox)
alert("Please download Firefox");
|
Taken from this page, as I didn't have time to write the code myself 
As star war fanatic pointed out, that code will which he gave will alert all non-firefox users to download firefox.
And if you give anyone the 20 Frih$, give it to hunnyhiteshseth, as I just built off of his code to give you what you wanted.
I am probably going to give it to both of you, but first I have to ask, what kind of code is that?
Oh I'm sorry, I got my code mixed up, and gave you the php code I found
Here is Javascript:
| Code: |
if (navigator.userAgent.indexOf("Firefox")== -1)
alert("Please download Firefox"); |
And that code does work, I tested it
Sorry for the confusion.