View Full Version : Drowser Based Message
Briton
11-27-2005, 07:39 PM
Hi!
I was wondering if any of you guys could help me find a script that would show a message based on browser, For example say that i built a script for ie only and someone with netscape tried to use it it would display a warning.
Anyone know?
Thanks
jscheuer1
11-27-2005, 08:23 PM
I like the title idea better. I think that is what we need sometimes. As things stand these days, this is a fairly good test of IE/Not IE:
if(!document.documentElement.filters){
alert ("Get IE, the most widely used browser because, I don't know how to code for other browsers.")
}
else {
alert("Ah, I see you've IE!")
}
Tongue firmly in cheek I think you can see that I don't think this is the very best of ideas. A better approach is (if there is any doubt that it is universally supported) to test for each method that you are using, providing an alternative method that is either supported by all or most other browsers. Sometimes there just isn't (or you can't figure one out) a good alternative. In a case like that, most of the time you can just skip the 'special effect' for other browsers and the script can still perform its basic function or (depending upon what that function is) the page can stand alone in other browsers without the script. Either way, there is no need to make any announcement about it.
This last idea is really key. Your page should be accessible to all browsers even if they have javascript turned off. That way, any twists and turns you take in a script won't matter, as long as no logical or coding errors are made.
If you were to give me the specifics of the script and the HTML it is meant to work with, I can probably come up with a way to make the script work cross browser, or at least degrade gracefully under those browsers that do not support it.
ddadmin
11-28-2005, 09:24 AM
jscheuer1 is right, you really shouldn't be forcing your users to be using one browser or the other in order for your site to look right. If certain JavaScripts on your page do not work in a certain browser, as long as it's done gracefully (no JS error pops up), that's a good enough compromise. If you like to learn how to modify scripts yourself to degrade nicely in non compatible browsers, this is a good object detection tutorial. (http://javascriptkit.com/javatutors/objdetect.shtml)
As for detecting non IE users, there are a million ways, some more reliable than others, I think something like this should do nicely:
<script type="text/javascript">
if (!document.all && !window.opera)
alert("You are NOT using IE4+!")
</script>
Briton
12-04-2005, 05:37 PM
THANKS!
Im going to try thoses BRB. . .
Briton
12-05-2005, 02:32 AM
ALRIGHT!!! IT WORKED. I PUT IT ON MY SITE. CHECK IT OUT AT HTTP://WWW.THEEASYMAIL.COM
THANKS GUYS!
cr3ative
12-05-2005, 10:57 AM
Connection has timed out
The server at www.theeasymail.com is taking too long to respond.
cr3ative
12-05-2005, 10:59 AM
Oh, it's loading now. Very slow server.
A message box really isn't the best way to do that. You should consider just making your site cross-browser compatible ;)
-cr3
P.S - Having too many keywords will cause Google to see your site as irrelavent, and will lower your search ranking.
P.P.S - Ack, you paid for that web design from Websites4u? ACK!
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.