预期错误对象 [英] Error Object Expected

查看:68
本文介绍了预期错误对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个让我疯狂。这个脚本在Firefox上运行得很好,

但是Internet Explorer一直在抱怨预期的错误对象

等等。我已经通过Firefox的Java控制台运行了它,并且

它没有错误地返回。关于这一点的任何指示,都会很赞赏。


< script type =" text / javascript">

<! -

var p = new Array(0,0,0,0,0)

var c = new Array(0,0,0, 0,0,0,0,0,0)


var classes = new Array(5)

classes [0] ="< a href =''javascript :class(0)''> ASM2O< \ / a>< div

id =''c0''>< \ / div>< a href =''javascript :class(1)''> PPL2O< \ / a>< div

id =' 'c1''>< \ / div>"

classes [1] ="< a href =''javascript :class(2) ''> SNC2D< \ / a>< div

id =''c2''>< \ / div>< a href =''javascript :class(3)''> CHC2D< \ / a>< div

id =''c3''>< \ / div>"

classes [2] ="< a href =''javascript :class(4)''> ENG2D< \ / a>< div

id =''c4''>< \ / div>< a href =''javascript :class(5)''> MPM2D< \ / a>< ; div

id =''c5''>< \ / div>"

classes [3] ="< a href ='' javascript :class(6)''> break< \ / a>< div

id =''c6''>< \ / div> ;"

classes [4] ="< a href =''javascript :class(7)''> GLC2O< \ / a>< ; div

id =''c7''>< \ / div>< a href =''javascript :class(8)''> BBI2O< \ / a>< div

id =''c8''>< \ / div>"


var hom = new Array(8)

hom [0] ="< ul>< li>补间动画< \ / li>< li>形状

补间< \ / li>< li> Splice< \ / li>< li>动作指南< \ / li>< \ / ul>"

hom [1 ] ="< ul>< li> Stuff< \ / li>< \ / ul >"

hom [2] ="< ul>< li> Megatransect II< \ / li>< li>工作表< \ / li>< li> 10.3

#1-14< \ / li>< \ / ul>"

hom [3] ="< ul>< li> ; Stuff< \ / li>< \ / ul>"

hom [4] ="< ul>< li>阅读2.1< \ / li>< ; li>重做期刊< \ / li>< \ / ul>"

hom [5] ="< ul>< li> Stuff< \ / li> < \ / ul>"

hom [6] ="< ul>< li>您认为您可以从午餐中获得作业

期间?< \ / li>< \ / ul>"

hom [7] ="< ul>< li>技术职业介绍< \ / li>< ; \ / ul>"

hom [8] ="< ul>< li> Stuff< \ / li>< \ / ul>"


功能显示(期间){

if(p [期间] == 0){

document.getElementById(" p" +周边od).innerHTML = clas ses [期间]

p [期间] = 1

}

else {

document.getElementById(" p" + period).innerHTML =""

p [period] = 0

}

}


函数类(num){

if(c [num] == 0){

document.getElementById(" c" + num).innerHTML = hom [num]

c [num] = 1

}

else {

document.getElementById(" c" + num).innerHTML =""

c [num] = 0

}

}

// - >

< / script>

-------------- -------------------------------------------------- ------------

您可以在此处查看上下文中的脚本:
http://www.freewebs.com/cisbase/Mich.../homework.html


它的要点是,点击一个链接,调用显示(句号)。

这将显示t来自类[]的适当元素在

转向提供了一个调用class(num)的链接,并显示了

对应的元素来自hom []


再次,在Firefox上运行良好。


Internet Explorer:

加载后,它会出现此错误:

行:42

字符:10

错误:预期''(''

代码:0

单击其中一个链接时会出现此错误

行:1

字符:1

错误:预期对象

代码:0

This one is driving me insane. The script works perfect on Firefox,
but Internet Explorer keeps complaining about "Error Object Expected"
and stuff like that. I''ve run it through Firefox''s Java Console, and
it comes back with no errors. Any pointers on this, would be much
appreciated.

<script type="text/javascript">
<!--
var p = new Array(0,0,0,0,0)
var c = new Array(0,0,0,0,0,0,0,0,0)

var classes = new Array(5)
classes[0] = "<a href=''javascript:class(0)''>ASM2O<\/a><div
id=''c0''><\/div><a href=''javascript:class(1)''>PPL2O<\/a><div
id=''c1''><\/div>"
classes[1] = "<a href=''javascript:class(2)''>SNC2D<\/a><div
id=''c2''><\/div><a href=''javascript:class(3)''>CHC2D<\/a><div
id=''c3''><\/div>"
classes[2] = "<a href=''javascript:class(4)''>ENG2D<\/a><div
id=''c4''><\/div><a href=''javascript:class(5)''>MPM2D<\/a><div
id=''c5''><\/div>"
classes[3] = "<a href=''javascript:class(6)''>break<\/a><div
id=''c6''><\/div>"
classes[4] = "<a href=''javascript:class(7)''>GLC2O<\/a><div
id=''c7''><\/div><a href=''javascript:class(8)''>BBI2O<\/a><div
id=''c8''><\/div>"

var hom = new Array(8)
hom[0] = "<ul><li>Motion tweening<\/li><li>Shape
tweening<\/li><li>Splice<\/li><li>Motion guides<\/li><\/ul>"
hom[1] = "<ul><li>Stuff<\/li><\/ul>"
hom[2] = "<ul><li>Megatransect II<\/li><li>Worksheet<\/li><li>10.3
#1-14<\/li><\/ul>"
hom[3] = "<ul><li>Stuff<\/li><\/ul>"
hom[4] = "<ul><li>Read 2.1<\/li><li>Redo journal<\/li><\/ul>"
hom[5] = "<ul><li>Stuff<\/li><\/ul>"
hom[6] = "<ul><li>You think you can get homework from a lunch
period?<\/li><\/ul>"
hom[7] = "<ul><li>Technology careers presentation<\/li><\/ul>"
hom[8] = "<ul><li>Stuff<\/li><\/ul>"

function display(period){
if(p[period]==0){
document.getElementById("p"+period).innerHTML=clas ses[period]
p[period]=1
}
else{
document.getElementById("p"+period).innerHTML=""
p[period]=0
}
}

function class(num){
if(c[num]==0){
document.getElementById("c"+num).innerHTML=hom[num]
c[num]=1
}
else{
document.getElementById("c"+num).innerHTML=""
c[num]=0
}
}
//-->
</script>
----------------------------------------------------------------------------
You can see the script in context here:
http://www.freewebs.com/cisbase/Mich.../homework.html

The gist of it, is that a link is clicked which calls display(period).
This will then display the appropriate element from classes[] which in
turn provides a link that calls class(num) and displays the
corresponding element from hom[]

Again, works nice on Firefox.

Internet Explorer:
Upon loading, it gives this error:
Line: 42
Char: 10
Error: Expected ''(''
Code: 0

And when clicking one of the links it gives this error
Line: 1
Char: 1
Error: Object Expected
Code: 0

推荐答案


我们********* @ gmail.com 写道:
这个让我疯了。该脚本在Firefox上运行良好,但是Internet Explorer一直在抱怨预期的错误对象等等。我已经通过Firefox的Java控制台运行了它,并且它没有错误地返回。任何关于此的指示都会很受欢迎。
This one is driving me insane. The script works perfect on Firefox,
but Internet Explorer keeps complaining about "Error Object Expected"
and stuff like that. I''ve run it through Firefox''s Java Console, and
it comes back with no errors. Any pointers on this, would be much
appreciated.




" class"是JScript中的保留字,您不能将其用作标识符。


将此表保持在您的comp附近:

< http:// msdn。 microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56jsconreserved.asp>



"class" is a reserved word in JScript, you cannot use it as identifier.

Keep this table near of your comp:
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56jsconreserved.asp>


> "类"是JScript中的保留字,你不能用它作为标识符。


Gah,我应该知道,感谢你的快速反应。

> "class" is a reserved word in JScript, you cannot use it as identifier.

Gah, I should have known that, thanks for the quick response.


>脚本在Firefox上工作得很好,
>The script works perfect on Firefox,
但是Internet Explorer一直在抱怨预期的错误对象这样的东西。我已经通过Firefox的Java控制台运行了它,并且它没有错误地返回。
but Internet Explorer keeps complaining about "Error Object Expected"
and stuff like that. I''ve run it through Firefox''s Java Console, and
it comes back with no errors.




另一个我经历过的案例完全相同的行为是

我已经离开了var在变量创建/赋值上,变量

被赋予一个对象。 IE不喜欢这样,但Firefox似乎接受了它。在这些情况下,输入var不可避免地修复了

问题。


不完全是你的具体情况,但似乎是另一种情况

相同弹出错误。



Another case where I''ve experienced EXACTLY the same behavior is when
I''ve left off "var" on a variable creation/assignment, and the variable
is being assigned an object. IE doesn''t like that, but Firefox seems to
accept it. In these cases, putting in "var" inevitably fixes the
problem.

Not exactly your specific case, it seems, but it is another case where
the same error pops up.


这篇关于预期错误对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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