admin管理员组文章数量:1434828
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??
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??
Share Improve this question asked Feb 5, 2013 at 8:41 user1918096user1918096 1531 gold badge3 silver badges10 bronze badges 2- 1 what are you trying to acplish? especially with the "appendChild" part? - I don't think the error is in the first line. – OschtärEi Commented Feb 5, 2013 at 8:43
- How is that script embedded in your page? Is it the only script? – Bergi Commented Feb 5, 2013 at 8:47
2 Answers
Reset to default 2The problem should be in the 2nd line:
myDiv.style.cssText("position:absolute;z-index:999");
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;
I also got this in an attempt to check if a variable was an Element.
"notAnElement" instanceof Element
And it always throws the function expected
error.
document.createElement("div") instanceof Element
Successfully evaluates to true
I haven't implemented it yet, but my solution is to use a try/catch block.
本文标签: javascriptquotSCRIPT5002 function expectedquot error in IEStack Overflow
版权声明:本文标题:javascript - "SCRIPT5002 function expected" error in IE - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745615284a2666362.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论