What follows is core that i have used and investigated as far as i can without using editors on a cellpone:
// avoid loops within mobile site
if(document.getElementById("dmRoot") !== null)
document.writeln("dmRoot not null|");
var CurrentUrl = location.href;
// yes; current URL now in variable
var noredirect = document.location.search;
// variable acts empty
// index is -1 .. so "always" tests agent in match substrings
var amatch = "";
var TypesToMatch=/(iPhone|iPod|BlackBerry|Android|Mobile|webOS|Windows CE|IEMobile|Opera|HTC|LG-|LGE|Samsung|SEC-SGH|Symbian|Nokia|PlayStation|Nintendo DSi)/i
// original long code---v
// amatch = (navigator.userAgent.match(/(iPhone|iPod|BlackBerry|Android.*Mobile|BB10.*Mobile|webOS|Windows CE|IEMobile|Opera Mini|Opera Mobi|HTC|LG-|LGE|SAMSUNG|Samsung|SEC-SGH|Symbian|Nokia|PlayStation|PLAYSTATION|Nintendo DSi)/i));
// NavAgent="SaMsUnG here will match"; // gives amatch of SaMsUnG,SaMsUnG
amatch = (NavAgent.match(TypesToMatch));
// either amatch is null or is a string like "AbCd,AbCd" if AbCd was in either string
// regardles of case in other string.
if (noredirect.indexOf("no_redirect=true") < 0)
location.replace(MobileURL + "?url=" + encodeURIComponent(CurrentUrl));
// Now, if any of those mobile phones used, use my new code
My problem is that in practice, on a real cellphone (Andrioid) the re-direct does not work.
As a result, i did more extensive investigation of the match() as used in the code, and found that either amatch is null or is a string like "AbCd,AbCd" (ie: duplicated).
Looks weird to me,but adding "mozilla" to the list allowed me to check it out online and offline.
My conclusion is that even tho the cellphone is android "powered" its internal ID as reported back by navigator.userAgent does not have that character string in the contents.
Therefore, i cannot trust any of those provided designators as being correct for any of the implied cellphone IDs.
This is why i need a way to "send back" the IDs to somewhere i can look.
The document.location.replace() only "jumps" to the given location.
I do not know if there is a reliable way (via some script) to send a pre-calculated message from the cellphone as an e-mail, as simulating of texting appears to be not useful.