JS a Few Good functions $$ () _javascript Tips

Source: Internet
Author: User
Tags flush vars
Copy Code code as follows:



function Map (a,f) {f (a);}


function Getrand (a,b)


{


if (a)


{


b=b?b:0;


Return Math.floor (Math.random () *a+b);


}else


{


A = new Date ();


return D.gettime ();


}


}


function $ (a) {document.write (a);}


function $$ ()


{


var elements = new Array ();


for (var i = 0; i < arguments.length; i++)


{


var element = Arguments[i];


if (typeof element = = ' String ')


element = document.getElementById (element);





if (arguments.length = 1)


return element;





Elements.push (Element);


}


return elements;


}


function Fgetcookie (name)


{


var cookievalue = "";


var search = name + "=";


if (Document.cookie.length > 0)


{


offset = document.cookie.indexOf (search);


if (offset!=-1)


{


Offset + + search.length;


End = Document.cookie.indexOf (";", offset);


if (end = = 1) end = Document.cookie.length;


Cookievalue = unescape (document.cookie.substring (offset, end));


}


}


return cookievalue;


}


function J_get (name)


{


var js_get =self.window.document.location.href;


var start =js_get.indexof (name + ' = ');


if (start = = 1) return ";


var len = start + name.length + 1;


var end = Js_get.indexof (' & ', Len);


if (end = = 1) end = Js_get.length;


Return unescape (js_get.substring (len,end));


}


function Writecookie (name, value, hours)


{


var expire = "";


var domain = "; Domain=jb51.net; path=/";


if (Hours!= "")


{


expire = new Date (new Date ()). GetTime () + hours * 60 * 60 * 1000);


expire = "; Expires= "+ expire.togmtstring ();


}


Document.cookie = name + "=" + Escape (value) + domain;


}


function Createxmlhttp ()


{


var ret = null;


try {


ret = new ActiveXObject (' msxml2.xmlhttp ');


}


catch (e) {


try {


ret = new ActiveXObject (' microsoft.xmlhttp ');


}


catch (ee) {


ret = NULL;


}


}


if (!ret && typeof xmlhttprequest!= ' undefined ')


ret = new XMLHttpRequest ();


return ret;


}


function Loadxmltoelement (Fragment_url, Element_id,mode,de)


{


var element = $$ (element_id);


var xmlhttp = createxmlhttp ();


var str;


Xmlhttp.open ("Get", fragment_url);


Xmlhttp.onreadystatechange = function ()


{


if (xmlhttp.readystate = = 4 && xmlhttp.status = 200)


{


if (!mode)


{


str = xmlhttp.responseXML.getElementsByTagName ("Data") [0].childnodes[0].nodevalue;


if (!element.innerhtml)


{


try{


str = Xmlhttp.responsexml.firstchild.childnodes[1].nodevalue;


}catch (e) {}


}


}else if (mode = = ' txt ')


{


str = Xmlhttp.responsetext;


}


if (de) str = unescape (str);


element.innerhtml = str;


}


}


Xmlhttp.send (NULL);


}


var Ojson = new Object ();


var Fjson =


{


' Data ': {},//[0,y,yes, null value]: default, [ -1,n,no]: Do not run flush (),


' file ': {},//additional JS code file


"str": {},//additional JS code


' Set ': function (element,vars)


{


For (key in VARs)


{


This[key][element] = Vars[key];


}


},


"Getsrc": function (Element)


{


var rs = ';


if (this[' data '][element])


{


if (this[' data '][element] = = ' n ' | | | this[' data '][element] = = '-1 ' | | this[' data '][element] = = ' no ')


{


RS + + ' &gjsondata=n ';


}


}


if (this[' str '][element])


{


RS + + ' &gjsondostr= ' +escape (this[' str '][element]);


}


if (this[' file '][element])


{


RS + + ' &gjsondofile= ' +escape (this[' file '][element]);


}


Return RS;


},


"Main": Function (Url,element,un)


{


UN = un?un:0;


Eval ("Ojson.") +element+ "= new Fjson.__json (' +url+" ', ' +element+ ', ' "+un+ ')");


},


"__json": function (Url,element,un)


{


var a = document.getElementById ("Script_" +element)


if (!a)


{


A = document.createelement ("script");


A.setattribute ("id", "script_" +element);


}


a.un = un;


A.data = ';


A.SRC = url+ (Url.indexof ('? ') = = 1)? '? ': ' & ') + ' gjson= ' +element+fjson.getsrc (Element);


if (Navigator.appVersion.indexOf ("msie") = = 1)


{


document.getElementById (Element). InsertBefore (A,null);


}else


{


Document.body.insertAdjacentElement ("Beforebegin", a);


}


return A;


},


"Flush": function (Element)


{


document.getElementById (Element). InnerHTML = (ojson[element].un)? Unescape (Ojson[element].data): Ojson[element]. Data


Ojson[element] = null;


}


}


/* Application * *


function Subpageselect (b,e,d,a)//b start E End D default a action


{


var shtml = ' <select ' +a+ ' > ';


for (Var i=b;i<=e;i++)


{


shtml+= ' <option value= ' ' +i+ ' ' + (i==d?shtml+= ' selected ': ') + ' > ' +i+ ' </option> ';


}


shtml+= ' </select> ';


return shtml;


}


function Err (A,B,C)


{


if (b)


{


if (c)


{


a.src= ' http://www.jb51.net/space/imgs/all/thu_woman.gif ';


}else


{


a.src= ' yun_qi_img/user_no_photo.gif ';


}


}else


{


a.src= ' yun_qi_img/flv_no_photo.gif ';


}


}


function Img_onerr (a)


{


Err (a);


}


function Gowin (a)


{


Document.location = A;


}


function Copyinboard (hahaurl,note)


{


Note = note?note: ' Web Site Replication success! '


Window.clipboardData.setData (' text ', Hahaurl)


alert (note);


}


function Fdomask (A,f,s,c,p,color)//a element F Refresh modulation s style C content p transparency


{


A = $$ (a);


p = p?p:75;


s = ' <div style= ' + (s?s: ' Text-align:center; margin-top:40px; ') + ' > ' + (c?c: ' <img src= "http://www.jb51.net/space/imgs/all/loading.gif" border= "0"/> Data Loading ... ') + (f? ' [<a href= "javascript: ' +f+ '" > Refresh </a>] ': ') + ' </div> ';


color = color?color: ' #FFFFFF ';


if (a.innerhtml!= "")


{


Window.onunload = Fcheckstatus;


var objbrother = a.childnodes[0];


var B = document.createelement (' DIV ');


B.setattribute (' id ', ' maskdiv ');


b.style.textalign = "center";


B.style.position = "absolute";


B.style.filter = "Alpha (opacity=" +p+ ")";


B.style.opacity = (p/100);


B.style.mozopacity = (p/100);


B.style.khtmlopacity = (p/100);


B.style.width = a[' offsetwidth ']+ ' px ';


B.style.height = a[' offsetheight ']+ ' px ';


B.style.margin = "0px";


B.style.backgroundcolor = color;


A.insertbefore (B,objbrother)


b.innerhtml = s;


}


}


function Switchdisplay (obj1, Obj2)


{


Try


{


Obj1 = $$ (obj1);


Obj2 = $$ (OBJ2);


if (obj1.style.display== ')


{


Obj1.style.display= ' None ';


Obj2.style.display= ';


}


Else


{


Obj1.style.display= ';


Obj2.style.display= ' None ';


}


}catch (ex)


{


}


}


function Getflashplayer (vars,playurl,id,w,h)


{


Playurl = playurl?playurl: ' HTTP://WWW.JB51.NET/FLASHAPP/56 ';


id = id?id: ' Siteflvplayer ';


w = w?w: ' 440 ';


h = h?h: ' 371 ';


Ac_fl_runcontent (' codebase ', ' http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version= 7,0,0,0 ', ' width ', W, ' height ', h, ' ID ', id, ' src ', playurl, ' flashvars ', VARs, ' quality ', ' high ', ' scale ', ' noscale ', ' Wmode ', ' Transparent ', ' name ', id, ' salign ', ' lt ', ' pluginspage ', ' http://www.macromedia.com/go/getflashplayer ', ' Movie ', Playurl); End AC Code


}


function F_js_playobject (A,h,s,player)


{


h = ' www.jb51.net ';//#.


Player = player?player: '/flashapp/v_player_site_fp7_5.swf ';


Player = ' http://' +h+player;


s = s?s: ' width= ' 100% ' height= ' 100% ';





var _into = "";


_into = ' <div id= ' videoplayer ' > ';


_into + = ' <div id= ' playerinfo ' style= ' color: #ffffff; font-weight:bold;text-align:center;display:none; > Double-click the Player screen or click "Full Screen" to cancel or restore full screen </div> ';


_into + = ' <div id= ' flvPlayBack ' class= ' normalsize ' > ';


_into + = ' <object classid= ' clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 ' +s+ ' > ';


_into + = ' <param name= ' allowscriptaccess ' value= ' always '/> ';


_into + = ' <param name= ' movie ' value= ' +player+ '/> ';


_into + = ' <param name= ' quality ' value= ' high '/> ';


_into + + "<param name=" bgcolor "value=" #ffffff "/>";


_into + = ' <param name= ' flashvars ' value= ' & ' +a+ ';


_into + = ' <embed src= ' +player+ ' flashvars= ' & ' +a+ ' quality= ' high ' pluginspage= ' http://www.macromedia.com/go /getflashplayer "align=" Middle "allowscriptaccess=" Samedomain "type=" "Application/x-shockwave-flash" ' +s+ ' > ';


_into + = ' </embed> ';


_into + = ' </object> ';


_into + = ' </div></div> ';


_into + + "<div id=" Maskforie "style=" lexrus:expression (this.style.width=document.body.parentnode.scrollwidth); Aether:expression (this.style.height=document.body.parentnode.scrollheight);d isplay:none;background: #000; filter : Alpha (opacity=70);p osition:absolute!important;left:0;top:0;width:100%!important; ></div> ';


_into = ' <style> #videoPlayer {margin:0;padding:0! important;width:440px;height:371px;} #program_player td{padding:0! important;} ';


_into = '. maxmized{z-index:9999;margin:0;padding:0;position:absolute;left:0;top:0;width:100%!important;height : 100%!important;filter:alpha (opacity=70);} ';


_into + = '. maxmized #flvPlayBack {width:580px!important;height:490px!important;} ';


_into + = '. maxmized #PlayerInfo {width:580px!important;} ';


_into = '. normalsize{width:440px;height:371px;} #flvPlayBack {margin:auto;height:100%;} #PlayerInfo {width:440px;} </style> ';


_into = "<div style=" Text-align:center;margin-top:7px;margin-bottom:-8px;color:gray; "id=" PlayerInfo1 "> If it does not play properly, please click this <a href= "javascript:void (0);" onclick= "Switchdisplay (\ ' playerinfo1\ ', \ ' playerinfo2\ ');" > View Details </a></div> ';


_into + = ' <div style= ' background: #fffbee; border:2px solid #EDBB17; Margin-right:4px;margin-top:7px;margin-bottom: -8px;padding:12px;display:none "id=" PlayerInfo2 > The video will not play properly because of the following conditions, please download the Flash8.0 player. <a href= "Http://v.jb51.net/flashApp/Flash_AX80.exe" > click here to download </a><br>1. If you open the page, only the sound has no video screen <br> 2. The player could not load, the "red X" <br>3. The player can load, but the hint version is too low! <br><br> do not appear when the above situation can not play, please give us a reflection! <a href= "http://bbs.jb51.net/view.html?url=http://bbs.jb51.net/data/841/841800.html?sid=11212" target= "_blank "> Point this report </a><br><br>[<a href=" javascript:void (0); "onclick=" Switchdisplay (\ ' playerInfo1\ '), \ ' playerinfo2\ '); " > Close Details </a>]</div> ';





document.getElementById (' Js_playobject '). InnerHTML = _into;


Fcheckzoom ();


}


function Zoommovie () {


var objid= ' Videoplayer ';


var Videoobject=document.all?document.all[objid]:d Ocument.getelementbyid (ObjID);


var maskforie=document.all?document.all[' Maskforie ']:d ocument.getelementbyid (' Maskforie ');


var videoplayback=document.all?document.all[' FlvPlayBack ']:d ocument.getelementbyid (' FlvPlayBack ');


var playerinfo=document.all?document.all[' Playerinfo ']:d ocument.getelementbyid (' Playerinfo ');


var searchbox=document.all?document.all[' Nav_search_form ']:d ocument.getelementbyid (' nav_search_form ');


var ismaxmized=/.*maxmized.*/i.test (videoobject.classname);


if (ismaxmized) {


Videoobject.classname= ' normalsize ';


Videoobject.style.position= ';


Videoplayback.firstchild.bgcolor= ' FFFFFF ';


Playerinfo.style.display= ' None ';


Maskforie.style.display= ' None ';


Searchbox.style.display= ';


}else{


Window.scrollto (0,0);


Videoobject.classname= ' maxmized ';


videoobject.style.position= ' absolute ';


if (navigator.appName.lastIndexOf (' Explorer ')!=-1) {


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 () {Zoommovie ()}


}


function Fcheckzoom ()


{


var a = J_get (' FS ');


if (a==1)


{


Zoommovie ();


}


}


/* Menu/*


var isovermainmenu = false;


var isoversortmenu = false;


function ShowMenu (ID) {


var a = document.getElementById ("MainMenu"). getElementsByTagName ("a");


for (Var i=0;i<a.length;i++) {


A[i].onmouseover = function () {


if (this.classname!= "active") This.classname = "hover";


Showsortmenu (this.id);


Isovermainmenu=true;


}


A[i].onmouseout = function () {


if (this.classname!= "active") This.classname = "";


settimeout ("Showsortmenu" (' +id+ ")", 400);


Isovermainmenu=false;


}





if (a[i].id = = ID) {


A[i].classname = "active";


Showsortmenu (ID);


} else {


A[i].classname = "";


}


}


}


function Showsortmenu (ID) {


var a = document.getElementById ("Sortmenu");


A.onmouseover = function () {


Isoversortmenu=true;


}


A.onmouseout = function () {


Isoversortmenu=false;


}


if (!isoversortmenu &&!isovermainmenu) {


var B = document.getElementById ("Sortmenu"). getElementsByTagName ("ul");


for (Var i=0;i<b.length;i++) {


if (b[i].id = = "Sortmenu_" +id) {


B[i].classname = "active";


} else {


B[i].classname = "";


}


}


}


}


/*******************************/


var Gloginid = Fgetcookie ("member_id"); Login User ID


var gloginhost = Fgetcookie ("host"); Login Host Name


var gloginpass = Fgetcookie ("Pass_hex"); Pass


var gloginmember = Fgetcookie ("Member_login"); Member_login


var gnewmail = Fgetcookie ("NewMail"); New mail


var gkeepmail = Fgetcookie ("Keepmail"); Check the message for signs


var gloginuser = gloginid.substring (0,gloginid.indexof ("@")); Login user Name


var gislogin = (gloginhost!= "" && gloginuser!= "" && gloginpass!= "" && Gloginmembe R!= "")? True:false; Whether you are already logged in


var basedir = ' http://v.jb51.net:88/photo/';


var userdir = Fcaculateurl (Gloginuser);


function Fislogin ()


{


Return (Fgetcookie ("host")!= "" && Fgetcookie ("member_id")!= "" && Fgetcookie ("Pass_hex")!= "" &&am P Fgetcookie ("Member_login")!= "")? True:false;


}


function Fcaculateurl (userName)


{


var level1 = 0;


var level2 = 0;


var k = username.length;


var arr = new Array ();


for (Var i=0;i<k;i++)


{


Level1 + + username.charcodeat (i) *i;


Level2 + + username.charcodeat (i) * (2*i+1);


}


Level1 = level1% 100;


Level2 = level2% 100;


return level1+ '/' +level2;


}


Document.domain = "Jb51.net";


Window.focus ();


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.