Recently the project has written some JS, the level waits for enhances _javascript skill

Source: Internet
Author: User
Tags openid
Copy Code code as follows:

function Resumeerror () {
return true;
}
Window.onerror = Resumeerror;

function Showdd (obj) {
var DDS = document.getElementById (obj). getElementsByTagName ("DD");
var len = dds.length;
if (Dds[0].style.display = = "None") {
The action is to expand the menu to determine if there is a cookie in the
1, have, delete
2, no, do not perform operation
Changeshowmenu (obj);
for (var i = 0; i < len;i++) {
Dds[i].style.display = "";
}
}else{
This action is a hidden menu, and you need to determine whether the item is in the cookie:
1, have, do not perform operation
2, none, then add it at the end
Changehidemenu (obj);
for (var i = 0; i < len;i++) {
Dds[i].style.display = "None";
}
}
}

function Changeshowmenu (obj) {
var temp = GetCookie ("OpenID");
if (Temp.indexof (obj)!= "-1") {
temp = temp.replace (obj + ",", "")
Addcookie ("OpenID", temp,24);
}
}

function Changehidemenu (obj) {
var temp = GetCookie ("OpenID");
if (temp.indexof (obj) = = "-1") {
Addcookie ("OpenID", temp+obj+ ",", 24);
}
}


function GetCookie (sname) {//Get cookie
var acookie = Document.cookie.split (";");
For (Var j=0 j < Acookie.length; J + +) {
var acrumb = acookie[j].split ("=");
if (sname = = Acrumb[0])
return acrumb[1];
}
return null;
}

function Addcookie (objname,objvalue,objhours) {//Add cookies
var str = objname + "=" + ObjValue;
if (objhours > 0) {//0 does not set the expiration time, the cookie automatically disappears when the browser shuts down
var date = new Date ();
var ms = objhours*3600*1000;
Date.settime (Date.gettime () + ms);
str + = "; Expires= "+ date.togmtstring ();
}
Document.cookie = str;
}

Based on a comma-separated string, initialize the menu which needs to be hidden
function Initmenu (obj) {
var arrmenu = Obj.split (",");
for (var i = 0; i < arrmenu.length;i++) {
var DDS = document.getElementById (Arrmenu[i]). getElementsByTagName ("DD");
for (var j = 0;j < dds.length;j++) {
Dds[j].style.display = "None";
}
}
}

function $ (obj) {
return document.getElementById (obj);
}

function Delit () {
var cbxbool = 0;
for (var i = 0;i < cbxarray.length;i++) {
var obj = $ (cbxarray[i]);
if (obj.checked = = True) {
Cbxbool = 1;
Break
}
}

if (Cbxbool = = 1) {
var result = confirm (operation cannot be recovered, determine the current operation?) ");
if (result) {
return true;
}
}else{
Alert ("You have not selected");
return false;
}
return false;

}
Window.onload = function () {
var Lendl = document.getElementById ("Globalleft"). getElementsByTagName ("DL"). Length;
if (GetCookie ("OpenID") = = null) {
Addcookie ("OpenID", "Dl_c,dl_d,dl_e,dl_f,dl_g,dl_h,dl_i,dl_j,", 24);
}
Initmenu (GetCookie ("OpenID"));



var otable = document.getElementById ("table");
var trs = Otable.getelementsbytagname ("tr");
for (var i = 0;i < trs.length;i++) {
Trs[i].onmouseover = function () {
This.style.backgroundColor = "#F7F7F7";
}
Trs[i].onmouseout = function () {
This.style.backgroundColor = "#FFFFFF";
}
}
}

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.