Home > Web Front-end > JS Tutorial > body text

I have written some js in recent projects, but my level needs to be improved_javascript skills

WBOY
Release: 2016-05-16 18:56:36
Original
1045 people have browsed it
Copy code The code is 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"){
//This operation is to expand the menu, and you need to determine whether the item exists in the cookie
//1. If yes, delete
//2. None, no operation is performed
changeshowmenu(obj);
for(var i = 0; i < len;i ){
dds[i].style.display = "";
}
}else{
//This operation is a hidden menu. You need to determine whether the item exists in the cookie:
//1. If yes, do not perform the operation
// 2. If none, 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 cookie
var str = objName "=" objValue;
if(objHours > 0){//When it is 0, no expiration time is set, and the cookie automatically disappears when the browser is closed
var date = new Date();
var ms = objHours*3600*1000;
date.setTime(date.getTime() ms);
str = "; expires=" date.toGMTString();
}
document .cookie = str;
}

//According to a comma-separated string, which parts of the initialization menu need 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("The operation cannot be resumed, are you sure about the current operation? ");
if(result){
return true;
}
}else{
alert("You have not selected the item yet");
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";
}
}
}
Related labels:
js
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template