解决方案 »
- FusionCharts使用JavaScript加载图表
- 求教js问题
- 请教一个javascript写法
- [新手]怎么使一个对象上的触发事件改变另外一个对象的值?
- 我用javascript代码为表格新建了一行tr,并想当这个tr被onclick时执行myadd函数,我直接写newTr.onclick=myadd可以,可我要写newTr.oncli
- 怎么才能实现确认后再提交表单????
- 如何在弹出窗口中控制opener的select元素
- 如何实现CSDN论坛左边菜单的显示和隐藏????
- 大侠,帮我解决对编程的迷惘问题!!!
- 紧急求助,带记忆功能的导航菜单
- JS调用外部信息列表
- 哪位大牛能帮扣个网站效果,万分感谢!
在javascript中这些新奇玩意,看不到源代码,还真的不知所云。不过我想用绝对会用,因为在java中看多了用多了。
for (var key in obj) {
s += key + ": " + obj[key] + " ";
}
document.write (s);
Running this sample in Internet Explorer 8 and Internet Explorer 9 would print the following results:
All modes of Internet Explorer 8:
first: prop1 second: prop2 3: prop3
All modes of Internet Explorer 9:
3: prop3 first: prop1 second: prop2
Internet Explorer 8 does not include enumerations of properties that have the same name as built-in properties of a prototype object. All document modes in Internet Explorer 9 include these properties in the enumeration. The following sample illustrates this difference:var obj = { first: "prop1", toString : "Hello" }
var s = "";
for (var key in obj) {
s += key + ": " + obj[key] + " ";
}
document.write (s);Running this sample in Internet Explorer 8and Internet Explorer 9 would print the following results:
All modes of Internet Explorer 8:
first: prop1
All modes of Internet Explorer 9:
first: prop1 toString: Hello
To work around the bug you mentioned, we can code the following to take care of the two possibilities:
for(var p in {toString: null}) {
// If we get here, then the for/in loop works correctly, nothing bothers
......
}
// If we get here, it means that the for/in loop did not enumerate the toString property of the test object.
// We need to take care of some properties that may not be enumerated ourselves.
.......