Google recaptcha error, i.e. eleven

In IE 11, the following error appears:

SCRIPT5007: cannot get property "toString" from undefined or null reference recaptcha__iw.js (451, 41)

Is it possible that the error is in the script?

Work with Safari, Chrome and Firefox.

+10
source share
5 answers

Add this line to your script where the recaptcha _ * file is loaded. js

document.querySelector('body').setActive(); 
+2
source

Ruthi's answer works on IE, but not on Google Chrome (a runtime error), so to solve the cross browser you need to first make sure that the browser can handle querySelector().setActive

So put this javascript code before rendering the recaptcha:

 if(document.querySelector('body').setActive != undefined) { document.querySelector('body').setActive(); } 
+4
source

Add a meta in the HTML header to enable some HTML5 features for Internet Explorer 11 ..

 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 

If it does not work, open Compatibility View Settings and delete google.com
Open developer tools and go to the Emulation tab then change the Document Mode to the edge ..

If it still does not work, add this polyfill to the header.

 <script src="https://cdn.polyfill.io/v2/polyfill.js"></script> 

Actually invisible Recaptcha is already supported by Android Stock Browser 4.0+ too .. So you do not need to worry if only an old browser that is not supported ..

+2
source

just add this polyfill (taken from cdn.polyfill.io)

 (function(undefined) { // Symbol // A modification of https://github.com/WebReflection/get-own-property-symbols // (C) Andrea Giammarchi - MIT Licensed (function(Object, GOPS, global) { var setDescriptor; var id = 0; var random = '' + Math.random(); var prefix = '__\x01symbol:'; var prefixLength = prefix.length; var internalSymbol = '__\ x01symbol@ @' + random; var DP = 'defineProperty'; var DPies = 'defineProperties'; var GOPN = 'getOwnPropertyNames'; var GOPD = 'getOwnPropertyDescriptor'; var PIE = 'propertyIsEnumerable'; var ObjectProto = Object.prototype; var hOP = ObjectProto.hasOwnProperty; var pIE = ObjectProto[PIE]; var toString = ObjectProto.toString; var concat = Array.prototype.concat; var cachedWindowNames = typeof window === 'object' ? Object.getOwnPropertyNames(window) : []; var nGOPN = Object[GOPN]; var gOPN = function getOwnPropertyNames(obj) { if (toString.call(obj) === '[object Window]') { try { return nGOPN(obj); } catch (e) { // IE bug where layout engine calls userland gOPN for cross-domain 'window' objects return concat.call([], cachedWindowNames); } } return nGOPN(obj); }; var gOPD = Object[GOPD]; var create = Object.create; var keys = Object.keys; var freeze = Object.freeze || Object; var defineProperty = Object[DP]; var $defineProperties = Object[DPies]; var descriptor = gOPD(Object, GOPN); var addInternalIfNeeded = function(o, uid, enumerable) { if (!hOP.call(o, internalSymbol)) { try { defineProperty(o, internalSymbol, { enumerable: false, configurable: false, writable: false, value: {} }); } catch (e) { o[internalSymbol] = {}; } } o[internalSymbol]['@@' + uid] = enumerable; }; var createWithSymbols = function(proto, descriptors) { var self = create(proto); gOPN(descriptors).forEach(function(key) { if (propertyIsEnumerable.call(descriptors, key)) { $defineProperty(self, key, descriptors[key]); } }); return self; }; var copyAsNonEnumerable = function(descriptor) { var newDescriptor = create(descriptor); newDescriptor.enumerable = false; return newDescriptor; }; var get = function get() {}; var onlyNonSymbols = function(name) { return name != internalSymbol && !hOP.call(source, name); }; var onlySymbols = function(name) { return name != internalSymbol && hOP.call(source, name); }; var propertyIsEnumerable = function propertyIsEnumerable(key) { var uid = '' + key; return onlySymbols(uid) ? ( hOP.call(this, uid) && this[internalSymbol]['@@' + uid] ) : pIE.call(this, key); }; var setAndGetSymbol = function(uid) { var descriptor = { enumerable: false, configurable: true, get: get, set: function(value) { setDescriptor(this, uid, { enumerable: false, configurable: true, writable: true, value: value }); addInternalIfNeeded(this, uid, true); } }; try { defineProperty(ObjectProto, uid, descriptor); } catch (e) { ObjectProto[uid] = descriptor.value; } return freeze(source[uid] = defineProperty( Object(uid), 'constructor', sourceConstructor )); }; var Symbol = function Symbol(description) { if (this instanceof Symbol) { throw new TypeError('Symbol is not a constructor'); } return setAndGetSymbol( prefix.concat(description || '', random, ++id) ); }; var source = create(null); var sourceConstructor = { value: Symbol }; var sourceMap = function(uid) { return source[uid]; }; var $defineProperty = function defineProp(o, key, descriptor) { var uid = '' + key; if (onlySymbols(uid)) { setDescriptor(o, uid, descriptor.enumerable ? copyAsNonEnumerable(descriptor) : descriptor); addInternalIfNeeded(o, uid, !!descriptor.enumerable); } else { defineProperty(o, key, descriptor); } return o; }; var onlyInternalSymbols = function(obj) { return function(name) { return hOP.call(obj, internalSymbol) && hOP.call(obj[internalSymbol], '@@' + name); }; }; var $getOwnPropertySymbols = function getOwnPropertySymbols(o) { return gOPN(o).filter(o === ObjectProto ? onlyInternalSymbols(o) : onlySymbols).map(sourceMap); }; descriptor.value = $defineProperty; defineProperty(Object, DP, descriptor); descriptor.value = $getOwnPropertySymbols; defineProperty(Object, GOPS, descriptor); descriptor.value = function getOwnPropertyNames(o) { return gOPN(o).filter(onlyNonSymbols); }; defineProperty(Object, GOPN, descriptor); descriptor.value = function defineProperties(o, descriptors) { var symbols = $getOwnPropertySymbols(descriptors); if (symbols.length) { keys(descriptors).concat(symbols).forEach(function(uid) { if (propertyIsEnumerable.call(descriptors, uid)) { $defineProperty(o, uid, descriptors[uid]); } }); } else { $defineProperties(o, descriptors); } return o; }; defineProperty(Object, DPies, descriptor); descriptor.value = propertyIsEnumerable; defineProperty(ObjectProto, PIE, descriptor); descriptor.value = Symbol; defineProperty(global, 'Symbol', descriptor); // defining 'Symbol.for(key)' descriptor.value = function(key) { var uid = prefix.concat(prefix, key, random); return uid in ObjectProto ? source[uid] : setAndGetSymbol(uid); }; defineProperty(Symbol, 'for', descriptor); // defining 'Symbol.keyFor(symbol)' descriptor.value = function(symbol) { if (onlyNonSymbols(symbol)) throw new TypeError(symbol + ' is not a symbol'); return hOP.call(source, symbol) ? symbol.slice(prefixLength * 2, -random.length) : void 0; }; defineProperty(Symbol, 'keyFor', descriptor); descriptor.value = function getOwnPropertyDescriptor(o, key) { var descriptor = gOPD(o, key); if (descriptor && onlySymbols(key)) { descriptor.enumerable = propertyIsEnumerable.call(o, key); } return descriptor; }; defineProperty(Object, GOPD, descriptor); descriptor.value = function(proto, descriptors) { return arguments.length === 1 || typeof descriptors === "undefined" ? create(proto) : createWithSymbols(proto, descriptors); }; defineProperty(Object, 'create', descriptor); descriptor.value = function() { var str = toString.call(this); return (str === '[object String]' && onlySymbols(this)) ? '[object Symbol]' : str; }; defineProperty(ObjectProto, 'toString', descriptor); setDescriptor = function(o, key, descriptor) { var protoDescriptor = gOPD(ObjectProto, key); delete ObjectProto[key]; defineProperty(o, key, descriptor); if (o !== ObjectProto) { defineProperty(ObjectProto, key, protoDescriptor); } }; }(Object, 'getOwnPropertySymbols', this));}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {}); 
+1
source

I had to remove

 import '@babel/polyfill 

inside my js file in the bundle (through this Symbol.Iterator was overwritten and caused a problem).

0
source

Source: https://habr.com/ru/post/1273877/


All Articles