Home > Web Front-end > JS Tutorial > Static pages can also be previewed in different ways to display the list [original]_javascript skills

Static pages can also be previewed in different ways to display the list [original]_javascript skills

WBOY
Release: 2016-05-16 19:25:18
Original
1048 people have browsed it

In order to facilitate viewing of the content, I have specially added a preview list two list display methods
Written from 2006 to October, please indicate the source for reprintingScript House

Copy code The code is as follows:

//For list display mode
function changeshow(num){
var thenum=num,thestyle;
if (num==1){
thestyle="none";
setCookie("num","1", 6)
var elements1=document.getElementsByTagName("div");
for(var i=0;i if(elements1[i].id==' dxy'){
elements1[i].className='info2';
}
}
}else
{
the
setCookie("num" ,"0",6)
var elements2=document.getElementsByTagName("div");
for(var i=0;i if(elements2[i] .id=='dxy'){
elements2[i].className='info';
}
}
}
var elements=document.getElementsByTagName("div");
for(var i=0;i if(elements[i].id=='jb51'){
if(elements[i].style.display !=thestyle){
elements[i].style.display=thestyle;
}
}
}
}

function setCookie(name, value) // cookies setting JS
{
var argv = setCookie.arguments;
var argc = setCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
if(expires!=null)
{
var LargeExpDate = new Date ();
LargeExpDate.setTime(LargeExpDate.getTime() (expires*1000*3600*24)); 🎜> }
document.cookie = name "=" escape (value) ((expires == null) ? "" : ("; expires=" LargeExpDate.toGMTString()));
}

function getCookie(Name) //cookies read JS
{
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
return unescape(document.cookie.substring(offset, end))
else return ""
}
}


PS:
1. Your generated static file must have the words
. Of course, you can also change it at will. Note
the above code
var elements=document.getElementsByTagName("div");
Code
2. Calling method:




3. Attached poplist.js


try{
var dxynum=getCookie("num");
changeshow(dxynum);
}
catch(e){

}


Specific Application: http://www.jb51.net/html/list/list_1_1.htm

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