The Sea King Posted January 27, 2008 Share Posted January 27, 2008 I need a script that checks the internet browser and displays this message when the browser isn't Firefox: <table align="center" bgcolor="#b0e0e6"><tr><td>Website is best viewed with Firefox. <br><a href="http://www.frefox.com">Download Firefox Now <br> <img src="http://img146.imageshack.us/img146/1673/firefoxwx7.png"></a></td></tr></table> Edit: So far I only have this and I wish to add the above code. <html><head><script type="text/javascript">function detectBrowser(){var browser=navigator.appName;var b_version=navigator.appVersion;var version=parseFloat(b_version);if ((browser=="Netscape")){document.write("");}else{document.write("Get Firefox");}}</script></head><body onload="detectBrowser()"></body></html> Link to comment Share on other sites More sharing options...
Ingolme Posted January 27, 2008 Share Posted January 27, 2008 This should do it, though I don't really rely on Javascript's prowser detecting function.if(navigator.appName != "Netscape") {document.write('<table align="center" bgcolor="#b0e0e6"><tr><td>Website is best viewed with Firefox. <br><a href="http://www.frefox.com">Download Firefox Now <br> <img src="http://img146.imageshack.us/img146/1673/firefoxwx7.png"></a></td></tr></table>')} Link to comment Share on other sites More sharing options...
The Sea King Posted January 27, 2008 Author Share Posted January 27, 2008 thanks again. though I don't really rely on Javascript's browser detecting function.... what would you suggest? Link to comment Share on other sites More sharing options...
Ingolme Posted January 27, 2008 Share Posted January 27, 2008 thanks again. ... what would you suggest?My suggestion is to try to make your sites work on all browsers in the first place. It will show your visitors that you're a good web designer. Most people, if they're using Internet Explorer, will probably ignore your site and leave if you're telling them to download another browser. Link to comment Share on other sites More sharing options...
jeffman Posted January 27, 2008 Share Posted January 27, 2008 ... what would you suggest?For what you're doing, it's fine. I suspect Ingolme was deprecating the habit of browser checking.In other contexts, some people like to check the browser to see (guess) if a property or method exists, so that they could kludge around it. Today, the savvy hacker will simply check if the property exists, regardless of browser.A typical example:function doodah (event){ var e = event || window.event; return;} Now most of us will recognize the need for this since IE treats events differently than everyone else. But who knows? In the next version they might not. If so, checking for a browser would mean checking for a browser and a version number. Ick. This is actually the way folks did things years ago, and the nested if statements were ugly. Check for the property and you get the same function in fewer statements and less upkeep. Maybe no upkeep.But as I said, your application really does need to do it this way. Link to comment Share on other sites More sharing options...
The Sea King Posted January 27, 2008 Author Share Posted January 27, 2008 My suggestion is to try to make your sites work on all browsers in the first place. It will show your visitors that you're a good web designer. Most people, if they're using Internet Explorer, will probably ignore your site and leave if you're telling them to download another browser.It's just the table border in firefox looks better than in IE... Is there any way to make the border the same as in Firefox? Link to comment Share on other sites More sharing options...
Ingolme Posted January 27, 2008 Share Posted January 27, 2008 The only difference I see with the table borders in Firefox and Internet Explorer is that Firefox shows it darker.Something like this CSS could do:table,td { border-style: solid; }table { border-color: #999999 #000000 #000000 #999999; }td { border-color: #000000 #999999 #999999 #000000; } Link to comment Share on other sites More sharing options...
The Sea King Posted January 27, 2008 Author Share Posted January 27, 2008 ok. thanks.Edit: Is this alright? table,td { border-style: solid; border-collapse: collapse;}table { border-color: #999999 #000000 #000000 #999999; }td { border-color: #000000 #999999 #999999 #000000; }a:link {color: #ffffff; text-decoration: none; font-style: italic;}a:visited {color: #ffffff; text-decoration: none; font-style: italic;}a:hover {text-decoration: underline;} Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.