navigator.MaxTouchPoints returns 2 on Edge browser on windows laptop even though it is not a touch device - touch

Edge browser returns 2 for navigator.MaxTouchPoints. We use the property to detect a touch device. Is there another way to accomplish this?

I also have this behaviour. It is caused when a laptop has a multi-touch capable touchpad. There was even a microsoft issue for this (however has been removed)
If I run the following test from my edge (Microsoft Edge 44.18362.449.0 and HTML 18.18362) all values are green (which is invalid).
There are some proposed fixes here.
Update:
Unfortunatly the first test from the patrickhlauke testpage with a real touchscreen and the old edge revealed the following:
"Touch feature detect" => all red Which is plain wrong.
However the navigator.maxTouchPoints are different:
navigator.maxTouchPoints (real touchdisplay) = 10
navigator.maxTouchPoints (Touchpad) = 2
So I will do something like this:
if(Browser=edge && maxTouchPoints > 2) => real Touchdisplay
if(Browser == edge && maxTouchPoints <=2) only tochpad not real touch display
=> After 2021-03-09 when the old edge is EOL'd I will remove that code...

not sure whether you are using MS Edge (EdgeHtml) browser or MS Edge chromium browser. You also did not mention the version of the browser.
I tested with both browsers and based on my testing I found that navigator.MaxTouchPoints returns 0.
Test code:
<!DOCTYPE html>
<html>
<head>
<script>
alert("navigator.maxTouchPoints = " + navigator.maxTouchPoints);
</script>
</head>
<body>
</body>
</html>
Output:
If you are using an older version then I suggest update it with the latest version and again make a test.
If the issue persists then try to provide the detailed information with snapshots may help to narrow down the issue.

Related

How to diagnose failed validation of Word Add-In when it works on my own setup?

I'm developing an MS Word Add-In. I've tested it on both Windows and Mac, and it works fine for me. Microsoft requires its own validation of Add-Ins to make sure they work correctly, and my Add-In fails for them even though it works for me with the same version of Windows and Word.
I had a phone call with the Microsoft Validation team, and their only suggestion was that I post a question on Stack Overflow so here goes!
This is the version of Windows and Word that works for me but fails for the MS Validation team:
Windows 10 Pro OS build 18362.295
Word 2016 (Version 1908 in particular)
I submitted a very simple add-in to Microsoft for debugging purposes. This simple add-in has only a single button that just opens a web page in the user's default browser.
This is the relevant portion of the manifest:
<Control xsi:type="Button" id="PB.Home.Button">
<Label resid="PB.Home.Button.Label"/>
<Supertip>
<Title resid="PB.Home.Button.Title"/>
<Description resid="PB.Home.Button.Desc"/>
</Supertip>
<Icon> ... </Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>navigateToWebPage</FunctionName>
</Action>
</Control>
This is the entirety of FunctionFile.html:
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js" ></script>
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/Office.js" type="text/javascript"></script>
<script src="FunctionFile.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
This is the entirety of FunctionFile.js:
(function () {
Office.initialize = function (reason) {};
})();
function navigateToWebPage(event) {
window.open('https://www.example.com', '_blank');
event.completed();
}
On my computer, when the button is clicked, a browser tab is opened with the web page, but for the MS Validation team this message appears in the toolbar at the bottom of the Word window
but nothing else happens.
The message "Patent Bots GCP is working on your Examiner Statistics" is generated by Word and not by my add in. "Patent Bots GCP" is the name of the add in and "Examiner Statistics" is the button label (one of the short strings in the manifest).
Any suggestions for how I can find out what is failing for the Microsoft Validation team? They are not able to provide any details about the error other than what I've included here.
I hope a Microsoft engineer sees this and is able to help.
=====
Maybe it is a popup blocker issue? See this: https://www.tek-tips.com/viewthread.cfm?qid=949178
Following up on Ragavan's comment, I did some searching for unexpected behavior of window.open() on IE11 (IE11 is the browser used in MS Word on Windows 10).
I found this other SO question, that noted
In IE on Windows 10 with default settings, if I perform a
window.open() against an external internet site from a page on my
local machine or a server on my local network, I get null.
that question further noted that
Interestingly, if I turn on "Enable Protected Mode" for the Intranet
Zone (so that Protected Mode are the same in the Intranet Zone and
Internet Zone), then the problem goes away.
I suspect this explains why my add in works on my Windows 10 computer, but not on the validation team's Windows 10 VM.
Unfortunately, the solution proposed in the answer there (w = window.open('') followed by w.location = url) does not work in the Word add in.
While this doesn't fix my problem, hopefully it leads the way to a solution...
#gaefan. Just adding my answer too if any one will have the same problem in future.
If anyone trying to open the external site from their add-in using JS window.open will end up in Object Expected aka validation failure error definitely by Microsoft. It depends on various factors like Windows 10 Build version, Office version and the Browser used by Add-ins.
So to publish your add-in successfully in the App source:
Note: This method is a workaround . But in near future If the new edge chromium version is released. Browser used by Add-ins will be changed. Then the workaround can be eliminated.
Use Task Pane add-in approach if your want to open any external site from Add-in.
The reason for recommonding Task-pane add-in is you can make utilize the anchor tag in your HTML like below
<a
href="https://yourcompany.com/"
class="button-config"
target="_blank"
(click)="performOperation()"
>Sign up
</a>
The reason for click event is to trigger any analytics function or trigger logs or add your custom logic
This will definitely open the external site without changing any settings on your browser.
If you want to stick on with command based add-in try adding new Action or Control button to open a external site via anchor tag.
Hope it will help some one. Thanks

GWTBootstrap3 components rendering incorrectly in IE11

My page elements should appear in all browsers as follows:
I can only achieve this in IE11 by having the dev tools open during page load, otherwise the page generates as the following:
Summary
no rounded corners on box elements
no column alignment (bootstrap class "col-lg-2" on
all label elements)
Legend formatting not added
general alignment off
no smooth accordion transition - open or closed
This issue is only with IE11, the site works in chrome, firefox and even Safari without any additional plumbing. I have found some IE fixes on SO, but so far none of them have worked:
*.html - add meta information to use Edge engine
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<html>
<head>
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<![endif]-->
... html continues with rest of head
*.js - to prevent undefined console from blocking processing
if(!window.console) {
console.log(item);
}
I have been sure to use Ctrl F5 when reloading the page for testing, and have also restarted devmode to see if that makes a difference. I have also confirmed that the site is not running in compatibility mode by looking in the compatability settings.
Looking through the logs I can see that when the page loads with dev tools closed, the binding is carried out using user.agent=ie8, whilst with devtools open, the binding property is user.agent=gecko1_8. I thought IE11 should always use the gecko1_8 permutation - why could this not be happening?
(using GWT Version 2.7)
Not sure if this will be of any help.
We are using GWT (2.8, but I think it also worked with 2.7 in the past).
With GWT-Bootstrap3 (https://github.com/gwtbootstrap3/gwtbootstrap3) without any problems in IE11. I am not sure you are using the same bootstrap library ?
Anyway. We added the following line in our html file (as the first line of the head tag) :
<meta http-equiv="x-ua-compatible" content="IE=10">
I can not really remember how I came up with this line, but the version history states : "It is now possible to use IE11 in compatibility mode"
So it has to do something with fixing something in IE-11, using GWT and bootstrap 3 :-)

GWT 2.7: Warn users they are using an unsupported browser

I recently upgraded my application to GWT 2.7 from GWT 2.5. This has caused me to drop support for IE6 and IE7.
I would like to provide users with IE6 or IE7 with a warning that their browser is outdated and will not work. At the moment if you go to the app with one of those browsers, you get a blank screen.
I know there are a couple ways that I could hack something together but I would rather use the GWT way, rather than some hack. Is there a GWT hook for unsupported browsers?
Option (hack) One
Drop this into my main.html:
if(document.documentMode === 6 || document.documentMode === 7){
myUnsupportedBrowserWarningFunction();
}
Potential problem with this is that if someone is using a browser that GWT doesn't recognise and I don't recognise (mobile opera? Some other browser), they will still get a blank page.
Option (hack) Two
GWT looks for the compiled JS here:
gwt/myApp/ASDFKLSDJFLSFDJSLDFJLSJDFSDES.cache.js
When someone is using an unsupported browser the following is requested (and is not found):
gwt/myApp/undefined.cache.js
It would be possible to create undefined.cache.js and put your unsupported browser code there. This is obviously a brittle solution and will break with future GWT updates.
Option Three
A recent patch (available in GWT 2.7) allows you to provide a default
permutation (e.g. safari) if GWT can not detect the browser and with
deferred binding you can display a warning that the provided app might not
work correctly as the browser is generally unsupported by GWT.
-- J.
Source
I don't want to set a default permutation for unsupported browsers. I want the site to not work and to display a warning. So this solution doesn't really provide what I am looking for.
Similar Questions & Posts
The same question was asked for an eariler version of GWT in 2009. I hope that GWT has added some kind of hook or best practice in the last 6 years.
More info on setting a default (fallback) permutation
You should be able to use onLoadErrorFn for that: https://code.google.com/p/google-web-toolkit/issues/detail?id=8135
<script>
function gwtLoadError(errMsg) {
// GWT app couldn't load, reason in errorMsg
}
</script>
<meta name="gwt:onLoadErrorFn" content="gwtLoadError">
or possibly onPropertyErrorFn:
<script>
function gwtPropError(propName, allowedValues, actualValue) {
if (propName == 'user.agent') {
// unsupported browser
}
}
</script>
<meta name="gwt:onPropertyErrorFn" content="gwtPropError">
(I don't think user.agent.runtimeWarning would help in this case, but maybe have a look)
There is an easy way:
Conditional Comments
<!--[if lt IE 8]>
<p>You are using an unsupportet browser. Please perform an update</p>
<![endif]-->
I think Option 3 may be the best one, but there is a problem: This will start the actual application (which still may be incompatible).
If this is an issue and you want a clear warning, you can rewrite the permutation selection script (You would need to update the script with the upcoming GWT releases)
You will need to copy this source:
https://gwt.googlesource.com/gwt/+/2.7.0/user/src/com/google/gwt/useragent/rebind/UserAgentPropertyGenerator.java
You could add something like:
$wnd.Location.replace('nosupported.html');
between line 90 and 91

IE does not recognize my script

hello friends I have a big problem with internet explorer, I made a date validation using "select" with jquery, in Mozilla and crome works, but IE does nothing. Please I need help!
Your JS code calls for elements that aren't created in IE version less than 7 - thus it does nothing. See below:
<!--[if lt IE 7]>
<script type="text/javascript">
document.createElement("#date-star-month");
document.createElement("#date-star-year");
document.createElement("#date-finish-month");
document.createElement("#date-finish-year");
document.createElement("#date-star-month option");
document.createElement("#date-star-year option");
document.createElement("#date-finish-month option");
document.createElement("#date-finish-year option");
document.createElement("year_star");
document.createElement("year_finish");
</script>
<![endif]-->
This will not work in IE older than 7 - tested on 9, didn't work, until I ran IE9 in quasi-IE7 mode.
Additional pointers
Would be much easier to answer your question if you would be more specific.
Adding your code was a good move, do that from the start.
Too bad you didn't:
let us know what the validation function is supposed to do
on what browsers (with their versions) have you tested this
Also, if you state your intentions (why do you need that data validation, what it must do, etc.) you can get extra tips to achieve this in other (maybe better or easier) way.

Dojo addOnLoad, but is Dojo loaded?

I've encountered what seems like a chicken & egg problem, and have what I think is a logical solution. However, it occurred to me that others must have encountered something similar, so I figured I'd float it out there for the masses.
The situation is that I want to use dojo's addOnLoad function to queue up a number of callbacks which should be executed after the DOM has completed rendering on the client side. So what I'm doing is as follows:
<html>
<head>
<script type="text/javascript" src="dojo.xd.js"></script>
...
</head>
<body>
...
<script type="text/javascript">
dojo.addOnLoad( ... );
dojo.addOnLoad( ... );
...
</script>
</body>
</html>
Now, the issue is that I seem to be calling dojo.addOnLoad before the entire Dojo library has been downloaded the browser. This makes sense in a way, because the inline SCRIPT contents should be executed before the entire DOM is loaded (and the normal body onload callback is triggered).
My question is this - is my approach sound, or would it make more sense to register a normal/standard body onload JavaScript callback to call a function, which does the same work that each of the dojo.addOnLoads is doing in the SCRIPT block. Of course, this begs the question, why would you ever then use dojo.addOnLoad if you're not guaranteed that the Dojo library will be loaded prior to using the library?
Hopefully this situation makes sense to someone other than me. Seems like someone else may have encountered this situation.
Thoughts?
Best Regards,
Adam Rice
You're doing it correctly. External Javascript files are loaded and executed synchronously in order, so by the time it reaches your dojo.addOnLoad( ... ); Dojo has loaded. Use dojo.addOnLoad instead of window.onload for two reasons:
it fires earlier, because it utilizes DOMContentLoaded
it handles asynchronous loading of dojo.require by postponing the execution until all required scripts have been read
Explained in DojoCampus as (dojo.addOnLoad):
dojo.addOnLoad is a fundamental aspect
of using Dojo. Passing addOnLoad a
function will register the function to
run when the Dom is ready. This
differs slightly from document.ready
and body.onload in that addOnLoad
waits until all dojo.require() (and
their recursive dependencies) have
loaded before firing.
This might have nothing to do with your problem, but ive just had a case where I had the same symptoms. For me everything worked fine for Firefox, Chrome etc, but not IE8.
I was getting what looked like dojo not being loaded, an error in IE8 saying that dojo was undefined (but not all the time) and i could strip everything down to just style sheets and importing dojo and still get the error.
I was running a local google app engine development server. This looks to be based on pythons SimpleHTTPServer which in turn uses SocketServer.BaseServer. This has BaseServer.request_queue_size which defaults to 5 - i couldn't find anything in app engine which overrode this value so i guess the development google app engine server has an upper limit of 5 connections.
Using regedit and going to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings
“MaxConnectionsPerServer”=dword:00000010
“MaxConnectionsPer1_0Server”=dword:0000010
This shows that IE was going to try and open up to 10 simultaneous connections. I edited these two keys and made them 2 and restarted the computer, the problem went away.