Internet Explorer支持arguments.callee.name? [英] Does Internet Explorer support arguments.callee.name?

查看:161
本文介绍了Internet Explorer支持arguments.callee.name?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以使用

arguments.callee.caller.name

但这不适用于Internet Explorer (任何版本)。什么是正确的跨浏览器语法?是否有解决方案?

But this does not work in Internet Explorer (any version). What's the correct cross-browser syntax? Does a workaround exist?

推荐答案

除了 arguments.callee 在ECMAScript 5的严格模式下,有效地被淘汰并且完全不存在,主要的问题是在IE中的 Function 对象没有 / code>属性。它在一些浏览器中实现,特别是Firefox和最近基于WebKit的浏览器,但是是非标准的,并且实际上没有标准化的方法来获取函数名。

Apart from the fact that arguments.callee is effectively being phased out and is completely absent in ECMAScript 5 strict mode, the main issue is that Function objects in IE do not have the name property. It is implemented in some browsers, notably Firefox and recent WebKit-based browsers, but is non-standard, and indeed there is no standardized way to get hold of a function name.

唯一的选项是让你尝试从函数的字符串表示中解析名称,这是不是一个好主意。这里有一个(长)讨论: http:// groups .google.com / group / comp.lang.javascript / browse_frm / thread / b85dfb2f2006c9f0

The only option this leaves you is trying to parse the name from the function's string representation, which is not a good idea. There's a (long) discussion here about it: http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/b85dfb2f2006c9f0.

这篇关于Internet Explorer支持arguments.callee.name?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆