如下所示类:function apSecurityAdvance(objID)
{
this.appendTo = document.getElementById(objID);
this.appendTo.style.cssText="padding:3px;background-color:rgb(206,225,250);margin: 0 6px;";
this.frm = this.createAdvanceform();
}
apSecurityAdvance.prototype.createAdvanceform=function()
{
var button=document.createElement("input");//创建一个按钮,用于显示隐藏权限设定
button.value="Advance";
button.type="button";
button.style.cssText="float:left;font-size:9pt;border:1px #dddddd solid;padding:3px 1px 1px 1px;height:20px;margin-top:3px;margin-left:0px;";
button.onclick=function()
{
this.onclick(); //这样写会出错,怎么写才不会有问题?
};
}
apSecurityAdvance.prototype.onclick=function()
{
//处理代码
}
谢谢!
{
this.appendTo = document.getElementById(objID);
this.appendTo.style.cssText="padding:3px;background-color:rgb(206,225,250);margin: 0 6px;";
this.frm = this.createAdvanceform();
}
apSecurityAdvance.prototype.createAdvanceform=function()
{
var button=document.createElement("input");//创建一个按钮,用于显示隐藏权限设定
button.value="Advance";
button.type="button";
button.style.cssText="float:left;font-size:9pt;border:1px #dddddd solid;padding:3px 1px 1px 1px;height:20px;margin-top:3px;margin-left:0px;";
button.onclick=function()
{
this.onclick(); //这样写会出错,怎么写才不会有问题?
};
}
apSecurityAdvance.prototype.onclick=function()
{
//处理代码
}
谢谢!
解决方案 »
- JS方法IE和火狐不兼容的问题
- 按钮样式变换,这个按下另一个弹起
- JS自动刷新
- 如何用javascript在x64的系统中选择32位的浏览器
- 我想找一个能靠右放置的有多数级菜单的导航条的代码...........最好是能在IE5.0能用滴.....
- JS 根据iframe中内容被动触发或者怎么样被iframe页面调用
- 我想实现这个功能,谁给我提点建议
- 非常急,如何遍历页面内所有HIDDEN的值
- C#类里边用javascript实现出错时弹出提示对话框,很繁琐,javascript高手来看.
- 请问如何锁定一个web上的一个文本框?
- 表单内输入内容,DIV内相同的字就变为蓝色,其他的不变。
- 菜鸟求助,判断非空!
button.onclick=function()我添加事件源对象:button.onclick=function(oEvent)调试时发现oEvent为undefined,咋回事,怎样才能取道事件源对象
t添加参数
apSecurityAdvance.prototype.onclick=function(evnt)
{
//处理代码
}
button.onclick=function(event)
{};
在FF下会有对象,但在IE下不会有,IE下直接使用(window.)event对象就行了(仅在事件处理函数下有效)
button.onclick=function()
{
this.onclick(); //这样写会出错,怎么写才不会有问题?
};
这段代码的上面加一句
var _this=this;
然后将代码改成:
button.onclick=function()
{
_this.onclick();
};
function apSecurityAdvance(objID)
{
this.appendTo = document.getElementById(objID);
this.appendTo.style.cssText="padding:3px;background-color:rgb(206,225,250);margin: 0 6px;";
this.frm = this.createAdvanceform();
}
apSecurityAdvance.prototype.createAdvanceform=function()
{
var button=document.createElement("input");//创建一个按钮,用于显示隐藏权限设定
button.value="Advance";
button.type="button";
button.style.cssText="float:left;font-size:9pt;border:1px #dddddd solid;padding:3px 1px 1px 1px;height:20px;margin-top:3px;margin-left:0px;";
var targetThis = this;
button.onclick=function(e) {
var event = e || window.event;
//this.onclick(); //这样写会出错,怎么写才不会有问题?
targetThis.onclick();
};
}
apSecurityAdvance.prototype.onclick=function()
{
//处理代码
}看看我的代码和你的有什么不同