manuzi1
manuzi1

Reputation: 1128

Get rid of FormData.entries() in IE11

I need to get rid or skip FormData.entries() in IE11. I have the code to check for IE 11 from here: https://stackoverflow.com/a/22242528/1824579

        var formData = new FormData();

        ...

        if (!navigator.appVersion.indexOf('Trident/') > -1) { //is 29 in IE; -1 in Chrome
            for (var pair of formData.entries()) { //error in IE11
                ...
            }
        }

So all I want to achieve is, that if the Browser is IE11 it should skip this section. By now I am not able to achieve this. In the console i only get this error shown up: SCRIPT1004: Expected ';' Index(1094, 31) which is exactly after the word pair in this line: for (var pair of formData.entries()) {

I don't know why IE11 is coming so far, because a log or the result of navigator.appVersion.indexOf('Trident/') is 29 in IE11.

Upvotes: 1

Views: 134

Answers (2)

Lionel Rowe
Lionel Rowe

Reputation: 5926

for...of is not supported in IE11. This is a syntax-level issue that can't be solved by feature detection. Your best bet is to transpile your source code with something like Babel, targeting IE11.

Upvotes: 2

Manuel Cheța
Manuel Cheța

Reputation: 500

The issue might be with using the logical NOT operator. Checking "indexOf > -1" should do the trick or you may need to use an extra set of brackets:

if (!(navigator.appVersion.indexOf('Trident/') > -1))

Upvotes: 0

Related Questions