静态页面也可以实现预览 列表不同的显示方式 原创
人气:0
为了方便查看内容,我特别加了个 预览 列表 两个列表显示方式
写于2006-10月,转载请写明出处
//用于列表显示方式
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<elements1.length;i++){
if(elements1[i].id=='dxy'){
elements1[i].className='info2';
}
}
}else
{
thestyle=""
setCookie("num","0",6)
var elements2=document.getElementsByTagName("div");
for(var i=0;i<elements2.length;i++){
if(elements2[i].id=='dxy'){
elements2[i].className='info';
}
}
}
var elements=document.getElementsByTagName("div");
for(var i=0;i<elements.length;i++){
if(elements[i].id=='jb51'){
if(elements[i].style.display!=thestyle){
elements[i].style.display=thestyle;
}
}
}
}
function setCookie(name, value) //cookies设置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读取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、你的生成静态的文件中要有<div id=jb51>字样,当然你也可以随意更改注意
上述代码中的var elements=document.getElementsByTagName("div");
代码
2、调用方法:
<script type=text/javascript language=javascript src="list.js"></script>
3、附poplist.js
try{
var dxynum=getCookie("num");
changeshow(dxynum);
}
catch(e){
}
具体应用:https://m.qb5200.com/www.qb5200.com/html/list/list_1_1.htm
写于2006-10月,转载请写明出处
复制代码 代码如下:
//用于列表显示方式
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<elements1.length;i++){
if(elements1[i].id=='dxy'){
elements1[i].className='info2';
}
}
}else
{
thestyle=""
setCookie("num","0",6)
var elements2=document.getElementsByTagName("div");
for(var i=0;i<elements2.length;i++){
if(elements2[i].id=='dxy'){
elements2[i].className='info';
}
}
}
var elements=document.getElementsByTagName("div");
for(var i=0;i<elements.length;i++){
if(elements[i].id=='jb51'){
if(elements[i].style.display!=thestyle){
elements[i].style.display=thestyle;
}
}
}
}
function setCookie(name, value) //cookies设置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读取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、你的生成静态的文件中要有<div id=jb51>字样,当然你也可以随意更改注意
上述代码中的var elements=document.getElementsByTagName("div");
代码
2、调用方法:
复制代码 代码如下:
<script type=text/javascript language=javascript src="list.js"></script>
3、附poplist.js
复制代码 代码如下:
try{
var dxynum=getCookie("num");
changeshow(dxynum);
}
catch(e){
}
具体应用:https://m.qb5200.com/www.qb5200.com/html/list/list_1_1.htm
加载全部内容