WebGadget; FEATURE_BROWSER_EMULATION; Windows 10;
Posted: Sun Jul 09, 2017 4:46 pm
Hello!
I need help getting FEATURE_BROWSER_EMULATION running.
I have an HTA file with borwser detection.
When putting mshta.exe into registry ../Main/FeatureControl/FEATURE_BROWSER_EMULATION/mshta.exe, put
into HTML header and start my HTA, it gives
It changed the default entry to somewhat newer.
I tried this for PureBasic WebGadget like given example at http://www.purebasic.fr/english/viewtop ... ON#p505947, but no success.
Any comibnation of settings explained on https://msdn.microsoft.com/en-us/librar ... _emulation did not work.
Browser detection is always:
which is old version IE7.0
Of course, IE11 is installed on system...
Is webgadget not able to use FEATURE_BROWSER_EMULATION?
Thanks for any hint!
Here the PureBasic code:
here the html code:
I need help getting FEATURE_BROWSER_EMULATION running.
I have an HTA file with borwser detection.
When putting mshta.exe into registry ../Main/FeatureControl/FEATURE_BROWSER_EMULATION/mshta.exe, put
Code: Select all
<meta http-equiv="x-ua-compatible" content="ie=11">
Code: Select all
Browser name = Netscape
Full version = 5
Major version = 5
navigator.appName = Netscape
navigator.userAgent = Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729; rv:11.0) like Gecko
I tried this for PureBasic WebGadget like given example at http://www.purebasic.fr/english/viewtop ... ON#p505947, but no success.
Any comibnation of settings explained on https://msdn.microsoft.com/en-us/librar ... _emulation did not work.
Browser detection is always:
Code: Select all
Browser name = Microsoft Internet Explorer
Full version = 7.0
Major version = 7
navigator.appName = Microsoft Internet Explorer
navigator.userAgent = Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)
Of course, IE11 is installed on system...
Is webgadget not able to use FEATURE_BROWSER_EMULATION?
Thanks for any hint!
Here the PureBasic code:
Code: Select all
EnableExplicit
declare RegisterFeatureBrowserEmulation()
declare UnRegisterFeatureBrowserEmulation()
RegisterFeatureBrowserEmulation()
If OpenWindow(0, 0, 0, 600, 300, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
WebGadget(0, 10, 10, 580, 280, "file:///D:\REVIEW/HTA/Test.html")
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Procedure RegisterFeatureBrowserEmulation()
;===== Registry: temp setting to optimise web gadget: Use when Install Program ====
protected sglpValueName.s = GetFilePart(ProgramFilename());"C:\D\REVIEW\PureBasic\PureBasic_Compilation0.exe")
protected lglpData.l = 11001
protected lglpdwDisposition.l
protected igphkResult.i
If RegCreateKeyEx_(#HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", 0, #Null, #REG_OPTION_VOLATILE, #KEY_ALL_ACCESS, #Null, @igphkResult, @lglpdwDisposition) = #ERROR_SUCCESS
RegSetValueEx_(igphkResult, sglpValueName, 0, #REG_DWORD, @lglpData, SizeOf(LONG))
RegCloseKey_(igphkResult)
EndIf
EndProcedure
Procedure OpenHtml()
protected File2Read.s = GetCurrentDirectory() + "index.html"
OpenWindow(1, 0, 0, 0, 0, "",#PB_Window_BorderLess|#PB_Window_Maximize)
SetWindowColor(1,$660000)
WebGadget(0, 0, 0, WindowWidth(1), WindowHeight(1), File2Read)
EndProcedure
Procedure UnRegisterFeatureBrowserEmulation()
;==== Registry: temp setting to optimise web gadget: Use when uninstall program ====
protected sglpValueName.s = GetFilePart(ProgramFilename())
protected lglpData.l = 11001
protected lglpdwDisposition.l
protected igphkResult.i
If RegOpenKeyEx_(#HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", 0, #KEY_SET_VALUE, @igphkResult) = #ERROR_SUCCESS
RegDeleteValue_(igphkResult, sglpValueName)
RegCloseKey_(igphkResult)
EndIf
EndProcedure
here the html code:
Code: Select all
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="x-ua-compatible" content="ie=11">
<script>
function testFileCreation(){
var fso = new ActiveXObject("Scripting.FileSystemObject");
var a = fso.CreateTextFile("d:\\temp\\testfile.txt", true);
a.WriteLine("This is a test.");
a.Close();
}
window.resizeTo(480 * 2, 320 * 2);
window.onload = function (){
TA.innerText = navigator.userAgent;
};
var nVer = navigator.appVersion;
var nAgt = navigator.userAgent;
var browserName = navigator.appName;
var fullVersion = ''+parseFloat(navigator.appVersion);
var majorVersion = parseInt(navigator.appVersion,10);
var nameOffset,verOffset,ix;
// In Opera 15+, the true version is after "OPR/"
if ((verOffset=nAgt.indexOf("OPR/"))!=-1) {
browserName = "Opera";
fullVersion = nAgt.substring(verOffset+4);
}
// In older Opera, the true version is after "Opera" or after "Version"
else if ((verOffset=nAgt.indexOf("Opera"))!=-1) {
browserName = "Opera";
fullVersion = nAgt.substring(verOffset+6);
if ((verOffset=nAgt.indexOf("Version"))!=-1)
fullVersion = nAgt.substring(verOffset+8);
}
// In MSIE, the true version is after "MSIE" in userAgent
else if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
browserName = "Microsoft Internet Explorer";
fullVersion = nAgt.substring(verOffset+5);
}
// In Chrome, the true version is after "Chrome"
else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) {
browserName = "Chrome";
fullVersion = nAgt.substring(verOffset+7);
}
// In Safari, the true version is after "Safari" or after "Version"
else if ((verOffset=nAgt.indexOf("Safari"))!=-1) {
browserName = "Safari";
fullVersion = nAgt.substring(verOffset+7);
if ((verOffset=nAgt.indexOf("Version"))!=-1)
fullVersion = nAgt.substring(verOffset+8);
}
// In Firefox, the true version is after "Firefox"
else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) {
browserName = "Firefox";
fullVersion = nAgt.substring(verOffset+8);
}
// In most other browsers, "name/version" is at the end of userAgent
else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) <
(verOffset=nAgt.lastIndexOf('/')) )
{
browserName = nAgt.substring(nameOffset,verOffset);
fullVersion = nAgt.substring(verOffset+1);
if (browserName.toLowerCase()==browserName.toUpperCase()) {
browserName = navigator.appName;
}
}
// trim the fullVersion string at semicolon/space if present
if ((ix=fullVersion.indexOf(";"))!=-1)
fullVersion=fullVersion.substring(0,ix);
if ((ix=fullVersion.indexOf(" "))!=-1)
fullVersion=fullVersion.substring(0,ix);
majorVersion = parseInt(''+fullVersion,10);
if (isNaN(majorVersion)) {
fullVersion = ''+parseFloat(navigator.appVersion);
majorVersion = parseInt(navigator.appVersion,10);
}
document.write(''
+'Browser name = '+browserName+'<br>'
+'Full version = '+fullVersion+'<br>'
+'Major version = '+majorVersion+'<br>'
+'navigator.appName = '+navigator.appName+'<br>'
+'navigator.userAgent = '+navigator.userAgent+'<br>'
)
</script>
</head>
<body>
<input type="textbox" value="?"/>
<input type="button" value="o.k."/>
<br/>
<textarea id="TA" style="width:10cm; height:5cm"></textarea>
</body>
</html>