Solved Browser Detection and Pop-up Warning

August 8, 2010 at 16:28:31
Specs: Windows Vista, 2GB
Okay, so I have this website, http://www.catholiccorner.99k.org, and it is built for viewing in Google Chrome or Safari, so on the home page, I want to use javascript or something to detect the browser it is being viewed in and only if it is not Chrome or Safari, I want a warning message to pop-up. It would be wonderful if someone could give me the code I could use to do this with.

See More: Browser Detection and Pop-up Warning

Report •


✔ Best Answer
August 10, 2010 at 12:12:15
If you have access to a server side scripting scripting language like php, you might try here for a detection script.

With either method, I think you're going to need to learn a bit of coding to handle the returned browser based on what you need/want to occur.

Good luck. :)



#1
August 9, 2010 at 01:47:47
A pitfall of browser detection is trying to guess whether the client is brand-x browser; instead, you should determine whether or not the client supports the functionality you're aiming for.

For example,

if(some_object.attachEvent) {
   // MS branded
} else if(some_object.addEventListener) {
   // mozilla branded
} else {
   // something else
}

Find out what features Chrome/Safari support, and then test whether or not they can be invoked by the client. If not, show your warning.

HTH


Report •

#2
August 9, 2010 at 16:05:53
Hi, thanks for the help, but I have no idea how I would do that and have not a clue of how javascript works. I just wanted a premade code that I could copy and paste.

Report •

#3
August 10, 2010 at 02:25:31
I like this:

http://jreject.turnwheel.com/#

(Scroll down to the demo's)


Report •

Related Solutions

#4
August 10, 2010 at 12:12:15
✔ Best Answer
If you have access to a server side scripting scripting language like php, you might try here for a detection script.

With either method, I think you're going to need to learn a bit of coding to handle the returned browser based on what you need/want to occur.

Good luck. :)


Report •

#5
August 15, 2010 at 08:08:08
"it is built for viewing in Google Chrome or Safari"
NO! BAD IDEA!

The days are long past when you could get away with rejecting visitors who weren't using the "right" browser. You must accept all comers. Since not all browsers are equally capable or standards-compliant (some visitors will come in on IE6, shudder!), you have to gracefully degrade when they use obsolete browsers, or don't have Javascript turned on, or don't have a Flash plug-in, or have images turned off (screen reader for the blind, or a search engine), or....

As pointed out by others, it's a losing game to try to read the entrails of a GET and figure out what browser someone is using, and present different versions of your page. You can do some tricks in Javascript and CSS to accommodate different browsers, but you'll still have a high failure rate. Some browsers masquerade as others. Better to offer buttons to "downgrade" the page in specified ways, and pass that information on from page to page (save it in a cookie).


Report •

#6
August 15, 2010 at 11:57:38
@Phil, I am not sure you quite understand; I am not rejecting visitors, just simply suggesting that it would look better with a different browser. You can still view all the information and everything with non-compatible browsers, but the css I used makes it so that some background images are misplaced and sometimes not even there.

@fmwap and @shutat, I have yet to try your last suggestions, but have viewed http://jreject.turnwheel.com/# and I believe that will work for me. I will let you know once I try it.

Thank you all for all the help.


Report •

#7
August 19, 2010 at 20:44:38
explore get_browser() in php if you can do some server side scripting.

Report •

Ask Question