Lesson Code: http://www.developphp.com/video/JavaScript/How-to-Detect-User-Browser-JavaScript-Tutorial
Learn how to detect the user browser software using JavaScript. There are various different ways to go about obtaining the result. This script is written to best convey the logic to someone new to programming. We also make special considerations for modern versions of Internet Explorer browser detection in this exercise.
Original source
31 responses to “How to Detect User Browser JavaScript Programming Tutorial”
Hi… Are you there… Please provide me your mail id so that i can contact you… I want to have an script and am not getting it.
Please Help…
Worked excellent for firefox , chrome,Internet Explorer but not with edge it is saying chrome whenever i run the page i don't why please help me
I open the file on Opera and it detects wrongly Chrome!
Are you using php framework?
Hey is there any way to detect users internet speed using php or JavaScript and then display the website accordingly . I mean for 3g or WiFi users there will be videos and animations in the website but for 2g users or slow connection there will be text and static images. I hope u get my question. Please help me find the solution .
"I think is a hobby…", you're totally right!!
Thanks Adam a lot
Just noticed something:
for instance: if you lowercase this array. say i lower case c in Chrome, it reads safari instead
var ba = ["chrome","Firefox","Safari","Opera","MSIE"]
Thank You..great job.
Tried, didn't work properly, still didn't detect Edge and Vivaldi. Here is my suggested fix:
//…/
var ba = ["Vivaldi", "Trident", "Edge", "Chrome", "Firefox", "Safari", "Opera", "MSIE"];
//…/
Hope it will be helpful.
I like this because I love logic. And also, DOWN WITH INTERNET EXPLORER!
Hello, teacher. I'm french and I don't understand well Inglish. There is a french version of this course? PLEASE!!!
can i download your videos
great job sir Adam Khoury
WTF? this is from Edge 馃榾 — User-agent header sent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240
Thank you so much Mr.Khoury, you are a life saver! Also thank you for the work and time you devoted to this video.
you're awesom brother , you helped me a lot 馃榾 tnx
I recomand everyone try using a browser detection method based on feature detection.
I want to warn the user that a mavigator versi贸n is not working with mi web page. How to do it?
I want to warn the user that a mavigator versi贸n is not working with mi web page. How to do it?
Nice vid. Again. But when does the the kid takeover from you.
Pretty nifty!
This digression about Microsoft was hilarious 馃檪
nice tutorial sir , i like to have some light on detecting bots which visiting my site using php
How does this compare to something like Modernizr?
thanks!
I'd choose:
ba.some( function( browser ) {
if ( ua.indexOf( browser ) > -1 ) {
b = browser;
return true;
}
});
Or:
b = ba.filter( function( browser ) {
return ua.indexOf( browser ) > -1
})[0];
Or maybe even .reduce()
Wait, I know in THIS tutorial it does not matter, but what editor do you use?
Good video and funny joke about Microsoft…thanks
thanks brother
Just to test, I put the more common browsers like Chrome and Firebox at the end of the array and got some interesting results.
Edge and Chrome will return Chrome or Safari depending on which is earlier in the array.
Would Safari return only Safari and thus we have Chrome at the beginning to negate the mix-up?
Here is a PHP tutorial of doing something similar:
https://www.developphp.com/video/PHP/Browser-and-Operating-System-Detect-Array-Script