Read User Agent


function isMobile()
{
	var uAgent = context.getUserAgent().getUserAgent();
	if (((uAgent.match("iPhone") !== null || param.platform=="iphone") || (uAgent.match("Android") !== null || param.platform=="android") || uAgent.match("iPad") !== null) || isIframe == true)
	{
		return true;
	}	
	else
	{
		return false;
	}
}

function isAndroidCheck()
{
	var uAgent = context.getUserAgent().getUserAgent();

	if ((uAgent.match("Android") !== null || param.platform=="android") || isAndroid == true)
	{
		return true;
	}	
	else
	{
		return false;
	}
}

function isIpad()
{
	var uAgent = context.getUserAgent().getUserAgent();
	print(uAgent);
	if (uAgent.match("iPad") !== null || param.ipad == 'true')
	{
		return true;
	}	
	else
	{
		return false;
	}
}

function isAndroidTablet()
{
	var uAgent = context.getUserAgent().getUserAgent();

	if ((uAgent.match("Android") !== null && uAgent.match("mobile") == null) || param.tablet == 'true')
	{
		return true;
	}	
	else
	{
		return false;
	}
}

function isIphone()
{
	var uAgent = context.getUserAgent().getUserAgent();

	if (uAgent.match("iPhone") !== null || param.platform=="iphone")
	{
		return true;
	}	
	else
	{
		return false;
	}
}

function isIOS5()
{
	var uAgent = context.getUserAgent().getUserAgent();

	if ((uAgent.match("iPhone") !== null  || uAgent.match("iPad") !== null) && uAgent.match('OS 5') !== null)
	{
		return true;
	}	
	else
	{
		return false;
	}
}
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
No comments yetLogin first to comment...