js几个不错的函数 $$_javascript技巧_脚本之家

复制代码 代码如下:functionmap;}
functiongetRand { b=b?b:0; returnMath.floor; }else { a=newDate; } }
function$;} function$$() { varelements=newArray(); for(vari=0;i0) {
offset=document.cookie.indexOf; if { offset+=search.length;
end=document.cookie.indexOf; ifend=document.cookie.length;
cookieValue=unescape(document.cookie.substring; } } returncookieValue; }
functionJ_get { varjs_get=self.window.document.location.href;
varstart=js_get.indexOf; ifreturn”; varlen=start+name.length+1;
varend=js_get.indexOfend=js_get.length;
returnunescape(js_get.substring; } functionwriteCookie { varexpire=””;
vardomain=”;domain=jb51.net;path=/”; if {
expire=newDate+hours*60*60*1000);
expire=”;expires=”+expire.toGMTString(); }
document.cookie=name+”=”+escape+domain; } functioncreateXMLHttp() {
varret=null; try{ ret=newActiveXObject; } catch{ try{
ret=newActiveXObject; } catch{ ret=null; } }
if(!ret&&typeofXMLHttpRequest!=’undefined’) ret=newXMLHttpRequest();
returnret; } functionloadXmlToElement(fragment_url,element_id,mode,de)
{ varelement=$$; varxmlhttp=createXMLHttp(); varstr; xmlhttp.open;
xmlhttp.onreadystatechange=function() {
if(xmlhttp.readyState==4&&xmlhttp.status==200) { if {
str=xmlhttp.responseXML.getElementsByTagName[0].childNodes[0].nodeValue;
if { try{ str=xmlhttp.responseXML.firstChild.childNodes[1].nodeValue;
}catch{} } }elseif { str=xmlhttp.responseText; } if;
element.innerHTML=str; } } xmlhttp.send; } varoJson=newObject();
varfJson= { “data”:{},//[0,y,yes,空值]:默认,[-1,n,no]:不运行flush(),
“file”:{},//附加js代码文件 “str”:{},//附加JS代码 “set”:function { for {
this[key][element]=vars[key]; } }, “getSrc”:function { varrs=”;
if(this[‘data’][element]) {
if(this[‘data’][element]==’n’||this[‘data’][element]==’-1’||this[‘data’][element]==’no’)
{ rs+=’&gJsonData=n’; } } if { rs+=’&gJsonDoStr=’+escape; }
if(this[‘file’][element]) {
rs+=’&gJsonDoFile=’+escape(this[‘file’][element]); } returnrs; },
“main”:function { un=un?un:0;
eval(“oJson.”+element+”=newfJson.__Json(‘”+url+”‘,'”+element+”‘,'”+un+”‘)”);
}, “__Json”:function { vara=document.getElementById if {
a=document.createElement; a.setAttribute(“id”,”script_”+element); }
a.un=un; a.data=”;
a.src=url+==-1)?’?’:’&’)+’gJson=’+element+fJson.getSrc;
if(navigator.appVersion.indexOf { document.getElementById.insertBefore;
}else { document.body.insertAdjacentElement; } returna; },
“flush”:function {
document.getElementById.innerHTML=?unescape:oJson[element].data;
//oJson[element]=null; } } /*应用*/
functionsubPageSelect//b开始e结束d默认a动作 { varshtml=”; for {
shtml+=”+i+”; } shtml+=”; returnshtml; } functionerr { if {
a.src=’//www.jb51.net/space/imgs/all/thu_woman.gif’; }else {
a.src=”; } }else {
a.src=”; } }
functionimg_onerr; } functiongowin { document.location=a; }
functionCopyInBoard { note=note?note:’网址复制成功啦!’;
window.clipboardData.setData alert; }
functionfDoMask//a元素f刷新调函数s样式c内容p透明度 { a=$$; p=p?p:75;
s=”+(c?c:’数据加载中…’)+(f?'[刷新]’:”)+”;
color=color?color:’#FFFFFF’; if { //window.onunload=fCheckStatus;
varobjBrother=a.childNodes[0]; varb=document.createElement;
b.setAttribute; b.style.textAlign=”center”; b.style.position=”absolute”;
b.style.filter=”alpha”; b.style.opacity=; b.style.MozOpacity=;
b.style.KhtmlOpacity=; b.style.width=a[‘offsetWidth’]+’px’;
b.style.height=a[‘offsetHeight’]+’px’; b.style.margin=”0px”;
b.style.backgroundColor=color; a.insertBefore b.innerHTML=s; } }
functionswitchDisplay { try { obj1=$$; if(obj1.style.display==”) {
obj1.style.display=’none’; obj2.style.display=”; } else {
obj1.style.display=”; obj2.style.display=’none’; } }catch { } }
functiongetFlashPlayer {
playUrl=playUrl?playUrl:’//www.jb51.net/flashApp/56′;
id=id?id:’siteFlvPlayer’; w=w?w:’440′; h=h?h:’371′;
AC_FL_RunContent(‘codebase’,’
} functionf_js_playObject { h=’www.jb51.net’;//#..
player=player?player:’/flashApp/v_player_site_fp7_5.swf’;
player=’; s=s?s:’width=”100%”height=”100%”‘;
var_into=””; _into+=’

‘; _into+=’双击播放器屏幕或者点“全屏”可取消或恢复全屏

‘; _into+=’

‘; _into+=”; _into+=”; _into+=”; _into+=”; _into+=”;
_into+=”; _into+=”; _into+=”; _into+=”; _into+=’

‘; _into+=”; _into+=’

‘; _into+=’如果不能正常播放,请点此查看详情’;
_into+=’因以下情况,导致视频无法正常播放,请下载Flash8.0播放器。点此下载
1.如果打开页面只有声音没有视频画面
2.播放器无法加载,出现“红X”
3.播放器可以加载,但提示版本过低!

非上述情况下出现无法播放时,请给我们反映!点此报告

[关闭详情]’; document.getElementById.innerHTML=_into; FcheckZoom(); }
functionzoomMovie(){ varobjId=’videoPlayer’;
varvideoObject=document.all?document.all[objId]:document.getElementById;
varmaskForIe=document.all?document.all[‘maskForIe’]:document.getElementById;
varvideoPlayBack=document.all?document.all[‘flvPlayBack’]:document.getElementById;
varplayerInfo=document.all?document.all[‘PlayerInfo’]:document.getElementById;
varsearchBox=document.all?document.all[‘nav_search_form’]:document.getElementById;
varisMaxmized=/.*maxmized.*/i.test(videoObject.className); if{
videoObject.className=’normalSize’; videoObject.style.position=”;
videoPlayBack.firstChild.BGCOLOR=’ffffff’;
playerInfo.style.display=’none’; maskForIe.style.display=’none’;
searchBox.style.display=”; }else{ window.scrollTo;
videoObject.className=’maxmized’; videoObject.style.position=’absolute’;
if(navigator.appName.lastIndexOf{
videoObject.style.left=(document.body.parentNode.scrollWidth-600)/2;
videoObject.style.top=’30’; playerInfo.style.display=”;
maskForIe.style.display=”; } videoPlayBack.firstChild.BGCOLOR=’000000′;
} videoObject.onclick=function} } functionFcheckZoom; if; } } /*菜单*/
varisOverMainMenu=false; varisOverSortMenu=false; functionshowMenu{
vara=document.getElementById.getElementsByTagName; for(vari=0;i

相关文章