6
可能重复:
JavaScript function aliasing doesn't seem to workJavaScript的:通过局部变量引用主机功能
为什么不这项工作?
function foo() {
var g = document.getElementById;
g('sampleID');
}
这个错误被抛出在Chrome:Uncaught TypeError: Illegal invocation
...并在Firefox:Error: uncaught exception: [Exception... "Illegal operation on WrappedNative prototype object"
它工作在IE9测试版虽然!!
可能重复[JavaScript函数混淆似乎并没有工作(HTTP://计算器。 com/questions/1007340/javascript-function-aliasing-doesnt-seem-to-work) – 2011-02-06 23:13:37
你有没有试过,`g.call(document,'sampleID');`? – Pointy 2011-02-06 23:16:26