javascript调用外部函数的古怪方式
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页</title>
<script type="text/javascript">
var net = new Object();
net.ContentLoader = function(url,postback)
{
this.url = url;
this.postback = postback;
}
net.ContentLoader.prototype=
{
display:function()
{
//javascript的调用方式,感觉很古怪
//this.postback.call(this);
//为何不采取这种方式?产生结果是一样的
this.postback();
}
}
var funPostback = function()
{
alert("Hello javascript!");
}
function test()
{
var netObject = new net.ContentLoader("abc.aspx",funPostback);
netObject.postback();
}
</script>
</head>
<body>
<a href="javascript:test()">测试</a>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页</title>
<script type="text/javascript">
var net = new Object();
net.ContentLoader = function(url,postback)
{
this.url = url;
this.postback = postback;
}
net.ContentLoader.prototype=
{
display:function()
{
//javascript的调用方式,感觉很古怪
//this.postback.call(this);
//为何不采取这种方式?产生结果是一样的
this.postback();
}
}
var funPostback = function()
{
alert("Hello javascript!");
}
function test()
{
var netObject = new net.ContentLoader("abc.aspx",funPostback);
netObject.postback();
}
</script>
</head>
<body>
<a href="javascript:test()">测试</a>
</body>
</html>