Question:
Javascript detect browser?
?
2010-06-10 17:04:15 UTC
Hi, straight to the point:

I'm making a webpage and I've tested it on every browser and everything works perfect except on google chrome... I'd like to have something like a script which would detect google chrome users and warn them the webpage won't work 100% with it?
Five answers:
Jesdisciple
2010-06-10 17:13:28 UTC
Google Chrome uses the WebKit rendering engine, the same as Linux's Konqueror and, to an extent, Apple's Safari. I advise you to fix the issue rather than warning Chrome users away; if you post a URL I'll try to help with that.



If you can't figure out how to fix it otherwise but can diagnose the exact difference between Chrome and other browsers which causes it, see here:



http://www.quirksmode.org/js/support.html



Avoid browser detection as much as you can, and if you do resort to it only post the warning as you said. Do NOT completely lock Chrome users out of the site, as people have been known to do when Internet Explorer, Netscape, or Mozilla didn't agree with them.
anonymous
2010-06-10 17:20:54 UTC
yes javascript can detect web browsers and their OS and much more.



here is just a sample :



"





"



hope this helps the above prints out the clients browser and much more..





you just need this for what your doing:



document.write("Browser Name: " + navigator.appName);



document.write("Browser Version: " + navigator.appVersion);





and then just put those in variables and then plug those variables into a if statement that if the clients browser is google chrome version whatever if version matters then display a window saying to use other browers since we don't support google chrome or it would not be displayed properly.



something like this for example don't copy and paste since this isn't real code but the theory:



var browser = navigator.appName;

var version = navigator.appVersion;



if(browser == google chrome) {

alert("the website won't display properly please use another browser to view our site thanks.");

}



this is just concept.



hope this helps. the alert gives the user a popup window displaying that message. Basic stuff but you can build onto it on how you want to display the message.



Hope this helps.
AJMB
2010-06-10 17:11:17 UTC
I would check out w3 schools. Here is a link to a guide on browser detection.

http://www.w3schools.com/js/js_browser.asp



on load you could check the browser and then display a popup.
?
2016-11-29 03:20:41 UTC
html physique







This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...