Javascript 之apply()
1、对象的继承,一般的做法是复制:Object.extend
prototype.js的实现方式是:
Object.extend = function(destination, source){
for (property in source) {
destination[property] = source[property];
}
return destination;
}
除此之外,还有种方法,就是:Function.apply(当然使用Function.call也是可以的)
apply方法能劫持另外一个对象的方法,继承另外一个对象的属性
Function.apply(obj,args)方法能接收两个参数
obj:这个对象将代替Function类里this对象
args:这个是数组,它将作为参数传给Function(args-->arguments)
相关文档:
① JavaScript添加位置,添加位置错误,会引起JavaScript代码无法执行的问题。
<head runat="server">
<script type='text/javascript' language="javascript">
<!—
//“添加内容”
//-->
</script>
</head>
② 引用他处的脚本 ......
重点在于function scroll(),function clipShow()及以下for循环。
无缝滚动新闻的Javascript源代码,放在这里,有需要的时候可能用得上:
//CSS样式
<style>
.new_newsT{
padding-top: 10px;
padding-bottom: 8px;
}
.new_newsT .list {
CLEAR: both; MARGIN: 0px 6px 0px 10px
}
......
javascript:void(0)
刚开始都不知道是啥意思
其实就是一个死链接,什么事情都不做。
<a id="link_${user.account}" href="javascript:void(0);" onclick="changSubmit();" style="cursor:pointer;height:25px;width:60px;margin-top:10px;">发送email</a>
这句 ......
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>vForm表单验证程 ......