var Person1= { name:"tom", say:function(){ alert("my name is "+this.name); } } var Person2= { name:"cat", say:function(){ alert("我是 "+this.name); } } Person1.say();//my name is tom Person1.say.call(Person2);//my name is cat var empty ={}; Person1.say.call(empty);//my name is undefined /*call说明:对象1.方法A.call(对象2)的作用是,让对象2替代本身对象1,如果对象1涉及的属性对象2不存在,则视为undeifend*/ <input type="text" id="myText" value="将文本框作为对象"> <script> function Obj(){this.value="Obj变量";} var value="windows 全局 变量"; var Fun1={ //全局的this为window value:"内部方法全局变量", test:function(msg){ alert(msg+":"+this.value); } } Fun1.test("全局变量"); //内部方法全局变量 Fun1.test.call(window,"将window作为对象"); //windows 全局 变量 Fun1.test.call(document.getElementById('myText'),"将文本框作为对象"); //input text Fun1.test.call(new Obj(),"将方法作为对象"); //Obj变量 </script>
详细解决方案
call总结
热度:123 发布时间:2012-10-25 10:58:57.0
相关解决方案
- fatal error; call to a member function query() on a non-object异常求回答啊 php+sqlite
- log4j:ERROR setFile(null,false) call failed.解决方法
- 关于httpWebRequest请求失败异常:The specified call count is not a number
- call stack 窗口怎么恢复
- 求问 什么是MO/MT call 啊解决思路
- call x"AF" using set-bit-pairs enable-esc-and-f1解决办法
- call esp怎么执行
- call 0229跟call si分别是什么寻址方式
- !call 为什么转不过去?
- call word ptr和call dword ptr有关问题
- call far ptr '标号'的有关问题[答案]
- db2创造PROCEDURE成功,但是运行db2 call TESTCASE() 会报错
- db2创建PROCEDURE成功,但是运行db2 call TESTCASE() 会报错,该怎么解决
- transfer: A call B, B hold A, B transfer C B Invite C的sip消息处理中,怎么知道A
- php连接mysql出错:Fatal error: Call to undefined function mysql_connect(),该如何处理
- thinkphp 有关问题 Call to undefined function
- 跟小弟我学aspectj之七 - call,execution,within,withincode
- 关于错 误 号:5异常描述:Invalid procedure call or argument
- Click-to-Call 或者 免费通 --免费电话解决办法
- Fatal error: Call to a member function query() on a non-object in G:\wamp\apache,该如何解决
- Call to undefined function bcompiler_write_header() 异常如何解决
- PHP对象编程有关问题,Call to a member function hello() on a non-object
- 【】Fatal error: Call to a member function * on a non-object
- Call to undefined function curl_init(),该怎么处理
- 求问下这个 Call to undefined function int()的缘故
- Fatal error: Call to undefined function curl_init()怎么解决
- 登录后台老板报错Fatal error: Call to undefined function _phpForKoXHbKBqn6BHxAmysql()
- php “Call to undefined function: mb_substr()”的解决办法
- php中出现“Call to a member function Execute() on a non-object”的有关问题
- phpmyadmin出现了Fatal error: Call to a member function getName() 如何都打不开了