前面的 第11篇文章 用到了这个版本的ADS.js
/**
* @author 赵磊 2009-04-25
*/
(function(){
//ADS命名空间 Advanced DOM Scripting
if(!window.ADS)
{
window.ADS={};
}
/********************************
* Chapter 1
*********************************/
//确定浏览器是否与整个库兼容
//例子 alert(ADS.getEvent());
function isCompatible(other){
if(other===false
||!Array.prototype.push
||!Object.hasOwnProperty
||!document.createElement
||!document.getElementsByTagName
){
return false;
}
return true;
}
window.ADS.isCompatible=isCompatible;
//依据id取得元素
//例子 ADS.$('bu1','bu2')
function $(){
var elements=new Array();
//查找作为参数提供的所有元素
for(var i=0;i<arguments.length;i++)
{
var element=arguments[i];
//如果该参数是一个字符串,假设它是一个id
if(typeof element=='string')
{
element=document.getElementById(element);
}
//如果只提供了一个参数,则立即返回这个元素
if(arguments.length==1)
{
return element;
}
//否则将它添加进数组
elements.push(element);
}
//返回包含多个被请求元素的数组
return elements;
}
window.ADS.$=$;
//添加事件
//例子 ADS.addEvent(window,'load',test6);
// ADS.addEvent(window,'load',test5);
//可以为一个对象添加多个事件
function addEvent(node,type_,listener){
//检查兼容性
if(!isCompatible()){return false;}
if(!(node=$(node))){return false;}
if(node.addEventListener)
{
//W3C的方法
node.addEventListener(type_,listener,false);
return true;
}else if(node.attachEvent)
{
//MS IE的方法
node['e'+type_]=listener;
node[type_]=function()
{
node['e'+type_](window.event);
}
node.attachEvent('on'+type_,node[type_]);
return true;
}
//若两种方法都不具备
return false;
}
window.ADS.addEvent=addEvent;
//删除事件
//例子 ADS.removeEvent(window,'load',test6);
function removeEvent(node,type,listener){
if(!(node=$(node))) {return false;}
if(node.removeEventListener)
{
//W3C的方法
node.removeEventListener(type,listener,false);
return true;
}
else if(node.detachEvent)
{
// MS IE 的方法
node.detachEvent('on'+type,node[type]);
node[type]=null;
return true;
}
//若两种方法都不具备
return false;
}
window.ADS.removeEvent=removeEvent;
//依据className 查找元素(集合)
//例子 ADS.getElementsByClassName("className","*",document);
//返回 数组
function getElementsByClassName(className,tag,parent){
parent=parent||documetn;
if(!(parent=$(parent))){return false;}
//查找所有匹配的标签
var allTags=(tag=="*"&&parent.all)?parent.all:parent.getElementsByTagName(tag);
var matchingElements=new Array();
//创建一个正则表达示
className=className.replace(/\-/g,"\\-");
var regex=new RegExp("(^|\\s)"+className+"(\\s|$)");
var element;
for(var i=0;i<allTags.length;i++)
{
element=allTags[i];
if(regex.test(element.className)){
matchingElements.push(element);
}
}
return matchingElements;
}
window.ADS.getElementsByClassName=getElementsByClassName;
//反复隐显
//例子 ADS.toggleDisplay('id');
// ADS.toggleDisplay('id','block');
function toggleDisplay(node,value){
if(!(node=$(node))){return flase;}
if(node.style.display!='none'){
node.style.display='none';
}else{
node.style.display=value||'';
}
return true;
}
window.ADS.toggleDisplay=toggleDisplay;
//在指定元素后面插入一个元素
//ADS.insertAfter("bu1","bu8")
//ADS.insertAfter(ADS.$("bu1"),ADS.$("bu8"))
function insertAfter(node,referenceNode){
if(!(node=$(node))){return false;}
if(!(referenceNode=$(referenceNode))){return false;}
return referenceNode.parentNode.insertBefore(node,referenceNode.nextSibling);
}
window.ADS.insertAfter=insertAfter;
//删除指定元素的所有子元素
function removeChild(parent){
if(!(parent=$(parent))) return false;
while(parent.firstChild){
parent.firstChild.parentNode.removeChild(parent.firstChild);
}
return parent;
}
window.ADS.removeChild=removeChild;
//给指定节点添加子节点, 添加在已有子节点的前面
//
function prependChild(parent,newChild){
if(!(parent=$(parent))) return false;
if(!(newChild=$(newChild))) return false;
if(parent.firstChild)
{
//如果存在一个 子节点,则在这个节点之前插入
parent.insertBefore(newChild,parent.firstChild)
}else{
//如果没有子节点,则直接插入
parent.appendChild(newChild);
}
return parent;
}
window.ADS.prependChild=prependChild;
// 获得事件对象
function getEvent(){
if(window.event)
{
return window.event;
}
var f=getEvent.caller;
while(f!=null)
{
var e = f.arguments[0];
if(e && (e.constructor==MouseEvent||e.constructor==Event||e.constructor==KeyboardEvent)) return e;
f=f.caller;
}
}
window.ADS.getEvent=getEvent;
/********************************
* Chapter 2
*********************************/
//把函数func,的上下文环境改为obj对象
function bindFunction(obj,func)
{
return function(){
func.apply(obj,arguments);
};
}
window.ADS.bindFunction=bindFunction;
/**
* Retrieve the size of the browser window.
*/
function getBrowserWindowSize() {
var de = document.documentElement;
// window.innerWidth for most browsers
// document.documentElement.clientWidth for MSIE in strict mode
// document.body.clientWidth for MSIE in quirks mode
return {
'width':(
window.innerWidth
|| (de && de.clientWidth )
|| document.body.clientWidth),
'height':(
window.innerHeight
|| (de && de.clientHeight )
|| document.body.clientHeight)
}
};
window['ADS']['getBrowserWindowSize'] = getBrowserWindowSize;
})();
分享到:
相关推荐
第2章 创建可重用的对象 2.1 对象中包含什么 2.1.1 继承 2.1.2 理解对象成员 2.1.3 window对象中的一切 2.1.4 理解作用域和闭包是根本 2.2 创建你自己的对象 2.2.1 一变多:...
第2章 创建可重用的对象 2.1 对象中包含什么 2.1.1 继承 2.1.2 理解对象成员 2.1.3 window对象中的一切 2.1.4 理解作用域和闭包是根本 2.2 创建你自己的对象 2.2.1 一变多:...
第2章 创建可重用的对象 2.1 对象中包含什么 2.1.1 继承 2.1.2 理解对象成员 2.1.3 window对象中的一切 2.1.4 理解作用域和闭包是根本 2.2 创建你自己的对象 2.2.1 一变多:...
12、 修正了表单向导SQL报错问题 Parse error: syntax error, unexpected ';' 修改了模板文件/formguide/header.html {php $types = cache_read('search_type.php');} 13、 修正了表单向导在系统没有安装到根...
document.writeln("<script type=\"text\/javascript\" src=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\"><\/script>") } if (code=="gg300x250_1"){//85849 GOOGLE document.write('...
注意微信观看功能要在conch/js/jquery.stem.js 这个文件夹修改相应的内容 第301行 幻灯片推荐9 大图模式需要上传海报图,建议尺寸1680px*580px 小图模式需设置3个推荐才显示 热播推荐1 建议推荐18个最jia(适配换...
/in_top2.js 二级目录头部文件 /in_copy.asp 一级目录底部文件 /in_copy2.js 二级目录底部文件 /index_mb.asp 首页模板 /search.asp 搜索 /play.asp 在线电影,FLASH播放 /error.asp 错误报告页 /admin/edit....
第二章 高级页面 引言:一些假设 17.装配高级搜索查询 18.同义词 19.在Google Box中获得Google搜索结果 20.使用Google指导烹饪 21.改变查询序列的组合方式 22.分析搜索结果的域频率 23.测量Google“记忆占有...
/in_top2.js 二级目录头部文件 /in_copy.asp 一级目录底部文件 /in_copy2.js 二级目录底部文件 /index_mb.asp 首页模板 /search.asp 搜索 /play.asp 在线电影,FLASH播放 /error.asp 错误报告页 /admin/edit....
2.网站各分类页面自动生成与更新信息与相关时间间隔设置(我要采购[1,2,3],我要销售[1,2,3],产品库[1,2,3],公司库[1,2,3])页面 3.新增设置新注册的会员的空间大小限制功能 4.新增会员空间大小操作限制 5.新增自定义...
2.版本增加了多语言的支持,方便更多用户使用,系统内所有显示和提示的信息完全由语言包控制。 3.定时任务目前内置了 采集资源、生成静态 2个执行操作,网址推送 4.可以直接在后台联盟采集中加入-并提供给他人采集。...
第二:打开你的footer.asp在合适的位置加入以下样式 代码 (一定是在“<style type="text/css"> 代码 </style>”): 引用: /******************************************** 中国移动...
易想商务V3.4升级说明 一、新风格使用说明 a) ...(修改ads/list.asp文件第八行及ads/edit.asp文件第九行路径为修改后的路径即可). b) 完善内容 Ø 完善会员注册页面显示Js及注册慢问题
js/home.js 系统内置功能的JS函数库 css/ 存放样式表文件 css/home.css 系统内置功能的样式表,例如 顶踩,联想搜索,星星评分,历史记录,留言本,评论等功能。 css/style.css 当前模版的自定义样式表 images/ ...
2、各个频道中分别设有栏目浏览方式 专题浏览方式两种,自如切换,使您的资料能够完成精准的分类; 3、各个频道均提供评论功能,并且支持“赠送鲜花”和“砸上鸡蛋”的评价功能; 4、网站设计简洁大方,全部采用...
Create React App入门 该项目是通过引导的。 可用脚本 在项目目录中,可以运行: npm start 在开发模式下运行应用程序。 打开在浏览器中查看它。 如果您进行编辑,则页面将重新加载。 您还将在控制台中看到任何...
5、修正了内容页面分页第一页为空问题 6、修正了专题多页分页时,导致500错误 7、修正了在没有开启php缓存时,问吧首页无法缓存问题 8、'FCKLang未定义'错误的解决办法问题:属编码问题,在本机使用记事本打开...
5、修正了内容页面分页第一页为空问题 6、修正了专题多页分页时,导致500错误 7、修正了在没有开启php缓存时,问吧首页无法缓存问题 8、'FCKLang未定义'错误的解决办法问题:属编码问题,在本机使用记事本打开...
其中第一个基于ww2 AT21 atu,这使得广泛的匹配成为可能。 使用伺服电机来控制高压电容器和开关,就可以做到这一点。 由于匹配的设计范围,高电压和高电流都是可能的。 pi零加入我的本地wifi网络,并将控制网页提供...