I found the code to set the userAgent at runtime in my application,in IE11 Chrome and FF by definegetter. Same doesn't work in IE10,9,8. Is this even possible? Referred Mocking a useragent in javascript?
EDIT
My Tryout code in IE 8 which didnt work.Error comes
Object doesnt support this action Object.defineProperty as said by TechLiam works in FF, Chrome and IE9+
if (navigator.appVersion.indexOf('MSIE 8.') != -1){
try
{
delete navigator;
}
catch(e)
{
//window["navigator"] = undefined;
if(Object.defineProperty){
Object.defineProperty(navigator,'userAgent',{
get: function() { return bValue; },
set: function(newValue) { bValue = newValue; },
configurable: true
});
}
}
}