“SCRIPT5002功能预期” IE中的错误 [英] "SCRIPT5002 function expected" error in IE

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

问题描述

我正面临一个问题,并在Internet Explorer 7-9中收到错误,如
SCRIPT5002功能预期。
这是我的代码:

i am facing an issue and getting error like "SCRIPT5002 function expected" in internet explorer 7-9. this is my code :

 var myDiv = document.getElementById("divId"); //this line gives me "SCRIPT5002 function expected" error.

 myDiv.style.cssText("position:absolute;z-index:999");
myDiv.appendChild(
        JavaScriptCode);

所以如何解决这个问题?

so how to solve this??

推荐答案

问题应该在第二行:

myDiv.style.cssText("position:absolute;z-index:999");

cssText 不是函数,而是属性。所以称之为像这样:

cssText is not a function, but a property. So call it like this:

myDiv.style.cssText = "position:absolute;z-index:999";

或(我认为更好的方法,因为它更清晰):

or (better approach in my opinion, because it is clearer):

myDiv.style.position = 'absolute';
myDiv.style.zIndex = 999;

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

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