A website I'm making has a separate set of files for mobile view due to the html layout being difficult to make responsive.
I'm looking for code that will detect if the user is on a mobile, then redirect them to the m.website.com domain instead.
I found this:
<script type=text/javascript>
if (screen.width <= 699) {
document.location = YOUR-MOBILE-SITE.com;
}
</script>
But on most mobile devices, there is an option to view the desktop version of websites, but it looks like this javascript will ignore that and keep redirecting anyway.
Is there a better way of doing this?