How to Detect User Browser JavaScript Programming

In this tutorial how to detect the user browser software using JavaScript. 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.

Example

<script>
	document.write(navigator.userAgent);
</script>

More Example

<script>
	var browser = ["Chroma","Firefox","Safari","Opera","MSIE","Trident","Edge"];
	var data, ua=navigator.userAgent;
	for(var i=0; i < browser.length; i++)
	{
		if(ua.indexOf(browser[i]) > -1)
		{
			data = browser[i];
			break;
		}
	}
	alert("You are using "+data+" browser ");
</script>

Leave a Reply

Your email address will not be published. Required fields are marked *