What I do now, but I don’t want to write it like this:
]
I hope to be able to do it when creating a calendar. There is no need to pass calendar1 in. In the setTimeout parameter, it can be executed directly through this.thread_result()
If you need to introduce external Js, you need to refresh to execute it
]
[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh it to execute
]
[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute
]
[Ctrl A Select all Note: <script>
function calendar(name){
this._name = name;
}
calendar.prototype.thread=function(){
this._timeout = setTimeout(this._name + ".thread_result()", 200);
}
calendar.prototype.thread_result=function(){
alert("执行成功!");
}
var calendar1;
onload=function(){
calendar1 = new calendar("calendar1");
calendar1.thread();
}
</script>If you need to introduce external Js, you need to refresh to execute <script>
function calendar(){
}
calendar.prototype.thread=function(){
this._timeout = setTimeout("this.thread_result()", 200);
}
calendar.prototype.thread_result=function(){
alert("执行成功!");
}
onload=function(){
var calendar1 = new calendar();
calendar1.thread();
}
</script>]<script>
function calendar(){
this.str="执行成功";
}
calendar.prototype.thread=function(){
var temp=this;
this._timeout = setTimeout(function(){temp.thread_result()}, 200);
}
calendar.prototype.thread_result=function(){
alert(this.str);
}
onload=function(){
var calendar1 = new calendar();
calendar1.thread();
}
</script><script>
Function.prototype.bindNode=function(oNode){
var foo=this,iNodeItem
if(window.__bindNodes==null)
__bindNodes=[]
__bindNodes.push(oNode)
iNodeItem=__bindNodes.length-1
oNode=null
return function(e){
foo.call(__bindNodes[iNodeItem],e||event)
}
}
btTest.onclick=function(){
alert(this.tagName==null?"tagName="+this.tagName+"(普通情况下,this指向当前函数)":"tagName="+this.tagName+"(经过bindNode处理后,this可以指向任意传过来的对象)")
}
window.setTimeout(btTest.onclick,100)
window.setTimeout(btTest.onclick.bindNode(btTest),200)
</script>Questions about binding events My approach is to write a function array myself I feel that this is more original. Please give me some advice ^^
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn