在测试多浏览器兼容时,发现chrome浏览器报Uncaught TypeError: object is not a function, 查找原因不得其所。
通过查看代码,发现在javascript中我定义了一个名称为onsubmit方法,后修改名称,发现chrome ok!
解决方案:
1.查询浏览器是否禁止脚本
2.查看javascript定义的对象名,是否与html中对象名称相同,尽量定义名称与之不同。
原文链接点这里。
补充
关于上面的第2点。举个例子,我在写代码的时候,html中有一部分是这样写的
<input type="button" value="计算结果" name="calculate" class="button" onclick="return calculate();">
注意,其中我这样写了: name="calculate",onclick="return calculate();"。
我定义的名为calculate方法和定义的calculate对象名称相同。
当我把 onclick="return calculate();" 修改为 onclick="return calculate_number();" 后,问题便得到了解决。
分享到:
相关推荐
is not a function`意味着调用了非函数类型的值,确保所调用的函数已正确定义。 对于数组操作,`TypeError: Cannot read property 'length' of undefined`表明尝试获取未定义变量的length属性。确保数组已被初始化...
layer.js:2 Uncaught TypeError: i is not a function at Object.o.run (layer.js:2) at layer.js:2 at layer.js:2 at layer.js:2问题 后来发现header头部引入js和css文件调换一下就好了,之间文件样式是这样的 ...
2. TypeError: ‘undefined’ is not an object (Safari) Safari浏览器会显示这个错误,与Chrome的"Cannot read property"类似,表示尝试访问未定义的对象。确保在访问属性或方法前对象已定义。 3. TypeError: ...
e){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function a(t){return"number"==typeof t}function n(t){return"object...
Uncaught TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them ``` 这是因为Babel默认启用了严格模式。为解决此...
### Laravel 5 异常错误: FatalErrorException in Handler...Uncaught TypeError: Argument 1 passed to App\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in D:\...
// => Uncaught TypeError: f4.log is not a function ``` 问题在于自定义的`_new`函数会直接返回构造函数的返回值,而不是我们期望的实例对象。要解决这个问题,我们可以修改自定义`_new`函数,使其不直接返回...
// Uncaught TypeError: Cannot assign to read only property 'foo' of object '#<Object>' } catch (e) { console.error(e); } ``` 4. **Reflect.get** 用于获取对象的属性值,类似于使用`.`或`[]`操作符。...
例如,试图访问未声明的`my`变量会得到`my is not defined`的错误。 2. **TypeError**:当变量或参数的类型不正确,或者尝试调用不存在的方法或属性时,会出现`TypeError`。例如,尝试对非构造函数使用`new`关键字...