• 全部
  • 问答

一个滑动门效果在vs2010里报错

寒舍人 2012-10-05 06:07:10
// JScript 文件<script type="text/javascript">
function switchmodTag(){
}
switchmodTag.prototype = {
st : function(menus,divs,openClass,closeClass){
var _this = this;
if(menus.length != divs.length)
{
alert("菜单层和内容层数量不一样!");
return false;
}
for(var i = 0 ; i < menus.length ; i++)
{
_this.$(menus[i]).value = i;
_this.$(menus[i]).onmouseover = function(){//此行onmouseover 可以改成onclick。

for(var j = 0 ; j < menus.length ; j++)
{
_this.$(menus[j]).className = closeClass;
_this.$(divs[j]).style.display = "none";
}
_this.$(menus[this.value]).className = openClass;
_this.$(divs[this.value]).style.display = "block";
}
}
},
$ : function(oid){
if(typeof(oid) == "string")
return document.getElementById(oid);
return oid;
}
}
window.onload = function(){
var STmodel = new switchmodTag();
STmodel.st(["a_1","a_2","a_3","a_4"],["a1_1","a1_2","a1_3","a1_4"],"menub1_1","menub1_2");//第一组动滑轮
STmodel.st(["b_1","b_2","b_3","b_4"],["b2_1","b2_2","b2_3","b2_4"],"menub3_1","menub3_2");//第四组动滑轮
STmodel.st(["c_1","c_2","c_3","c_4","c_5"],["c3_1","c3_2","c3_3","c3_4","c3_5"],"menub2_1","menub2_2");
STmodel.st(["d_1","d_2","d_3"],["d4_1","d4_2","d4_3"],"menub4_1","menub4_2");
STmodel.st(["e_1","e_2"],["e5_1","e5_2"],"menub5_1","menub5_2");
STmodel.st(["f_1","f_2","f_3"],["f6_1","f6_2","f6_3"],"menub5_1","menub5_2");
STmodel.st(["G_1","G_2","G_3","G_4","G_5"],["G7_1","G7_2","G7_3","G7_4","G7_5"],"menub6_1","menub6_2");
STmodel.st(["H_1","H_2"],["H8_1","H8_2"],"menub8_1","menub8_2");
STmodel.st(["J_1","J_2","J_3","J_4"],["J9_1","J9_2","J9_3","J9_4"],"menub8_1","menub8_2");
STmodel.st(["k_1","k_2","k_3"],["k10_1","k10_2","k10_3"],"menub5_1","menub5_2");
//第四组动滑轮
//如需增加个数,请复制代码,ID命名规则如上即可。
}



提示是_this.$(menus[i]).value = i;

Microsoft JScript 运行时错误: '$(...)' 为空或不是对象

在VS2005里正常,刚转到2010里报错了

...全文
70 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
寒舍人 2012-10-08
不知道,2010调试的时候报错2005不会报错
回复
兼哲 2012-10-05
我很好奇一个问题,js 报错和你的 vs 2010 有啥关系?

[Quote=引用楼主 的回复:]
// JScript 文件<script type="text/javascript">
function switchmodTag(){
}
switchmodTag.prototype = {
st : function(menus,divs,openClass,closeClass){
var _this = this;
if(menus.length != divs.lengt……
[/Quote]
回复
泡泡鱼_ 2012-10-05
看看你的页面中是不是都有那些元素存在吧
回复
发帖
JavaScript
创建于2007-09-28

8.5w+

社区成员

Web 开发 JavaScript
申请成为版主
帖子事件
创建了帖子
2012-10-05 06:07
社区公告
暂无公告