Reputation: 11
I have a problem with a vendor ONLY working with IE. I am opening a window and passing credentials. If it is Chrome/FireFox/etc they block it. I am able to successfully change the user agent to imitate IE but not in combo with opening a window.
openWindow('https://www.IEOnlyVendor.com?credentials=abc123');
var __originalNavigator = navigator; // alter user agent string to IE 11
navigator = new Object();
navigator.__proto__ = __originalNavigator;
navigator.__defineGetter__('userAgent', function () { return 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; MDDR; MS-RTC LM 8; rv:11.0) like Gecko'; });
Does anyone know how to do this? Perhaps create a window, change the user agent, then open the window.
Upvotes: 0
Views: 2346
Reputation: 25004
You might be able to try something similar to how this answer changes the user agent of an iframe.
The important part (I added contentWindow
param so you could (?) call on new window): calling this function after injecting contents into empty window.
var setUA = function(contentWindow) {
if (Object.defineProperty) {
Object.defineProperty(contentWindow.navigator, 'userAgent', {
configurable: true,
get: function () {
return 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5';
}
});
} else if (Object.prototype.__defineGetter__) {
contentWindow.navigator.__defineGetter__('userAgent', function () {
return 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5';
});
} else {
alert('browser not supported');
}
};
Upvotes: 1