| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1256 人关注过本帖
标题:JS问题很急,请各位看下。
只看楼主 加入收藏
foktime
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:奥斯维辛
等 级:贵宾
威 望:35
帖 子:795
专家分:2742
注 册:2009-9-4
收藏
得分:0 
无代码无真相
2010-08-12 09:41
liweilkm
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2010-8-11
收藏
得分:0 
回复 11楼 foktime
程序代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www. xmlns="http://www. http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>先成后台管理-详情</title>
<link href="Style/client.css" rel="stylesheet" type="text/css" />


<style type="text/css">

* {
    padding:0px;
    margin:0px;
}
img {
    border:0px;
}
body {
    font-family:"瀹嬩綋";
    font-size:12px;
    font-weight:normal;
}
ul, li, dl, dd, dt {
    list-style:none;
}
a {
    text-decoration:none;
    color:#000;
}
a:hover {
    text-decoration:underline;
    color:#F00;
}
h1, h2, h3, h4 {
    font-family:"瀹嬩綋";
    font-size:12px;
    font-weight:normal;
}
#box {
    width:1024px;
    height:730px;
    margin:0 auto;
}
/**Header**/
#header {
    width:1024px;
    height:93px;
    background:url(../images/xc_02.gif) repeat-x;
}
#h_logo {
    width:1024px;
    height:60px;
    float:left;
}
#h_logo h1 {
    width:68px;
    height:60px;
    padding-right:5px;
    float:left;
}
#h_logo h2 {
    float:left;
    width:300px;
    height:20px;
    font:bolder 20px "黑体";
    color:#ea5413;
    padding-top:30px;
}
#h_nav {
    width:534px;
    height:33px;
    float:left;
    margin-left:180px;}
.nav { WIDTH: 100%;  FONT-FaMILY: verdana; height:31px; font-family:arial, Helvetica, sans-serif; font-size:12px;}
.nav ul {PaDDING: 0px;  DISPLaY: block;  MaRGIN: 0px;  liST-STYLE-TYPE: none; HEIGHT: 31px; COLOR: #ffffff; }
.nav li { DISPLaY: block; FLOaT: left; HEIGHT: 31px; font-family:arial, Helvetica, sans-serif; font-size:12px; width:106px; text-align:center; line-height:31px;}
.nav li a {  DISPLaY: block;  FONT-WEIGHT: none;  COLOR: #847300; liNE-HEIGHT: 31px; TEXT-DECORaTION: none;}
.nav li a:hover {COLOR:#562505;  TEXT-DECORaTION: none;}
.current{ color:#ffffff; background:#006600; float:left; width:106px; height:31px;}
.nav li#date{ color:#ffffff; PaDDING:2px 15px 0; }
#btn {
    float:left;
    width:235px;
    height:24px;
    margin:4px 0 0 10px;
    display:inline;
}
#btn li {
    float:left;
    width:63px;
    height:24px;
    border-right:1px dashed #b5b6b6;
}
#btn li img {
    float:left;
    width:24px;
    height:24px;
    margin-right:5px;
}
#center {
float:left;
    width:1024px;
    height:auto;
    background:url(../images/xc_018.gif) repeat-x;
}
#c_left {
    width:165px;
    height:475px;
    background:#FFF;
    margin:7px 0 0 11px;
    display:inline;
    float:left;
}
#help_categories {
    width:157px;
    height:468px;
    background:#eff0f2;
    margin:4px 0 0 4px;
}
.classification {
    width:157px;
    float:left;
    height:auto;
}
.set_up {
    width:157px;
    float:left;
    height:auto;
}
.set_up h3 {
    text-align:center;
    background:#003300;
    height:auto;
    line-height:30px;
    font-size:12px;
    font-weight:bold;
    cursor:pointer;
}
.set_up h3.active {
    background:#996699;
    height:auto;
    line-height:47px;
    color:#FFF;
}
.set_up h3 a, .set_up a {
    color:#000000;
    display:block;
}
.set_up ul li {
    width:150px;
    float:right;
    line-height:25px;
}

/**Foot**/
#foot {
    float:left;
    width:1024px;
    height:30px;
    background:url(../images/xc_42.gif) repeat-x;
    line-height:30px;
    font-weight:bold;
    color:#676666;
}
#foot p {
    float:left;
    width:860px;
}

</style>



<script language="javascript">
function $(id) {
    return document.getElementById(id);
}
function showleftmenu(num){
    for (var i = 0; i < 3; i++) {
        $("help_center_leftmenu" + i).className = "";
        $("menu_content" + i).style.display = "none";
    }
    $("help_center_leftmenu" + num).className = "active";
    $("menu_content" + num).style.display = "block";
    SetCookie("flag", num);
}
function initfn() {
    if (getCookie('flag')) {
        var n = getCookie('flag');
        for (var i = 0; i < 3; i++) {
            $("help_center_leftmenu" + i).className = "";
            $("menu_content" + i).style.display = "none";
        }
        $("help_center_leftmenu" + n).className = "active";
        $("menu_content" + n).style.display = "block";
    }
}     

 
function showmenuitem(thisid){
     var items=document.getElementById("help_categories").getElementsByTagName("a");
    for(var i=0;i<items.length;i++){
        if(items[i].className=="style"){
            items[i].className="";
        }
    }
    thisid.className="style";
}
//写cookies函数
function SetCookie(name,value)//两个参数,一个是cookie的名子,一个是值
{
    var Days = 30; //此 cookie 将被保存 30 天
    var exp  = new Date();    //new Date("December 31, 9998");
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getCookie(name)//取cookies函数      
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr != null) return unescape(arr[2]); return null;

}
function delCookie(name)//删除cookie
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}


</script>



<script language="javascript">

///点击链接,首先记录cookie,然后跳转
function change_bg(thisA, num) {

 writeCookie('nav', num, 1);//写入cookie值,以便在另一页面调用,有效1分钟内
}

///页面载入后需自动执行的函数
function loadFN(){

 navA = document.getElementById("nav").getElementsByTagName("a");

 navCookie = readCookie('nav');

 if(navCookie) {
  for(key in navA) {
   navA[key].className = '';
  }
  navA[navCookie].className = 'current';

 }
}
///页面载入后执行js的loadFN函数
window.onload = loadFN;

///页面关闭时清除导航相关的cookie
//window.onunload = clearNavCookie;

///写入cookie值
function writeCookie(name, value, fens) {
  var expire = "";
  if(fens != null)
  {
    expire = new Date((new Date()).getTime() + fens * 60000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}

///读取名为name的cookie值
function readCookie(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;
}

///清除命名为cookieName的cookie
function clearNavCookie() {

 writeCookie('nav', null, 0);
}
</script>

</head>
<body  onload="initfn()">
<div id="box">
  <div id="header">
   
    <div id="h_nav">
      <div class="nav" id="nav">
  <ul>
    <li><a  href="file:///E:/先成管理系统/客户中心——列表1.html" class="current" onmousedown="change_bg(this, 0)">工作台</a></li>
    <li><a  href="file:///E:/先成管理系统/客户中心——列表1.html" onmousedown="change_bg(this, 1)">日程    </a> </li>
    <li><a  href="file:///E:/先成管理系统/客户中心——列表1.html" onmousedown="change_bg(this, 2)">任务中心</a> </li>
    <li><a  href="file:///E:/先成管理系统/客户中心——列表1.html" onmousedown="change_bg(this, 3)">我的任务(代办)</a> </li>
    <li><a  href="file:///E:/先成管理系统/客户中心——列表1.html" onmousedown="change_bg(this, 4)">客户中心</a> </li>


  
  </ul>
</div>
    </div>
    <div id="btn">
      <ul>
        <li><a href=""><img src="images/xc_12.gif" style="margin-left:5px;" /></a> <a href=""><img src="images/xc_14.gif" /></a></li>
        <li><a href=""><img src="images/xc_16.gif" style="margin-left:5px;"  /></a> <a href=""><img src="images/xc_18.gif" /></a></li>
        <li style=" border-right:none;"><a href=""><img src="images/xc_20.gif" style="margin-left:5px;"  /></a> <a href=""><img src="images/xc_22.gif" /></a></li>
      </ul>
    </div>
  </div>
  <div id="center">
    <div id="c_left">
<div id="help_categories">
        <div class="classification">
       
          <div class="set_up">
            <h3 id="help_center_leftmenu1"><a href="#" style="cursor:hand" onmousedown="showleftmenu(1)">项目浏览</a></h3>
            <ul id="menu_content1" style="display:none;">
          
            </ul>
          </div>
          <div class="set_up" style="margin-top:3px;">
            <h3 id="help_center_leftmenu2"><a href="#" style="cursor:hand" onmousedown="showleftmenu(2)">查询项目</a></h3>
            <ul id="menu_content2" style="display:none;">
          
            </ul>
          </div>
          <div class="set_up" style="margin-top:3px;">
            <h3 id="help_center_leftmenu0" class="active"><a style="cursor:hand" onmousedown="showleftmenu(0)">项目汇总</a></h3>
            <ul id="menu_content0">
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer" >·标志设计</a></li>
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer">·VI设计</a></li>
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer">·包装设计</a></li>
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer">·网站设计</a></li>
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer">·空间设计</a></li>
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer">·导示设计</a></li>
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer">·工业设计</a></li>
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer">·品牌顾问</a></li>
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer">·品牌命名</a></li>
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer">·广告设计</a></li>
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer">·传媒设计</a></li>
            </ul>
          </div>
        </div>
      </div>
    </div>
   
  </div>
  <div id="foot">
    <p>&nbsp;&nbsp;版权所有:</p>
    先成设计www.
2010-08-12 13:59
liweilkm
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2010-8-11
收藏
得分:0 
回复 11楼 foktime
程序代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www. xmlns="http://www. http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>先成后台管理-详情</title>
<link href="Style/client.css" rel="stylesheet" type="text/css" />


<style type="text/css">

* {
    padding:0px;
    margin:0px;
}
img {
    border:0px;
}
body {
    font-family:"瀹嬩綋";
    font-size:12px;
    font-weight:normal;
}
ul, li, dl, dd, dt {
    list-style:none;
}
a {
    text-decoration:none;
    color:#000;
}
a:hover {
    text-decoration:underline;
    color:#F00;
}
h1, h2, h3, h4 {
    font-family:"瀹嬩綋";
    font-size:12px;
    font-weight:normal;
}
#box {
    width:1024px;
    height:730px;
    margin:0 auto;
}
/**Header**/
#header {
    width:1024px;
    height:93px;
    background:url(../images/xc_02.gif) repeat-x;
}
#h_logo {
    width:1024px;
    height:60px;
    float:left;
}
#h_logo h1 {
    width:68px;
    height:60px;
    padding-right:5px;
    float:left;
}
#h_logo h2 {
    float:left;
    width:300px;
    height:20px;
    font:bolder 20px "黑体";
    color:#ea5413;
    padding-top:30px;
}
#h_nav {
    width:534px;
    height:33px;
    float:left;
    margin-left:180px;}
.nav { WIDTH: 100%;  FONT-FaMILY: verdana; height:31px; font-family:arial, Helvetica, sans-serif; font-size:12px;}
.nav ul {PaDDING: 0px;  DISPLaY: block;  MaRGIN: 0px;  liST-STYLE-TYPE: none; HEIGHT: 31px; COLOR: #ffffff; }
.nav li { DISPLaY: block; FLOaT: left; HEIGHT: 31px; font-family:arial, Helvetica, sans-serif; font-size:12px; width:106px; text-align:center; line-height:31px;}
.nav li a {  DISPLaY: block;  FONT-WEIGHT: none;  COLOR: #847300; liNE-HEIGHT: 31px; TEXT-DECORaTION: none;}
.nav li a:hover {COLOR:#562505;  TEXT-DECORaTION: none;}
.current{ color:#ffffff; background:#006600; float:left; width:106px; height:31px;}
.nav li#date{ color:#ffffff; PaDDING:2px 15px 0; }
#btn {
    float:left;
    width:235px;
    height:24px;
    margin:4px 0 0 10px;
    display:inline;
}
#btn li {
    float:left;
    width:63px;
    height:24px;
    border-right:1px dashed #b5b6b6;
}
#btn li img {
    float:left;
    width:24px;
    height:24px;
    margin-right:5px;
}
#center {
float:left;
    width:1024px;
    height:auto;
    background:url(../images/xc_018.gif) repeat-x;
}
#c_left {
    width:165px;
    height:475px;
    background:#FFF;
    margin:7px 0 0 11px;
    display:inline;
    float:left;
}
#help_categories {
    width:157px;
    height:468px;
    background:#eff0f2;
    margin:4px 0 0 4px;
}
.classification {
    width:157px;
    float:left;
    height:auto;
}
.set_up {
    width:157px;
    float:left;
    height:auto;
}
.set_up h3 {
    text-align:center;
    background:#003300;
    height:auto;
    line-height:30px;
    font-size:12px;
    font-weight:bold;
    cursor:pointer;
}
.set_up h3.active {
    background:#996699;
    height:auto;
    line-height:47px;
    color:#FFF;
}
.set_up h3 a, .set_up a {
    color:#000000;
    display:block;
}
.set_up ul li {
    width:150px;
    float:right;
    line-height:25px;
}

/**Foot**/
#foot {
    float:left;
    width:1024px;
    height:30px;
    background:url(../images/xc_42.gif) repeat-x;
    line-height:30px;
    font-weight:bold;
    color:#676666;
}
#foot p {
    float:left;
    width:860px;
}

</style>



<script language="javascript">
function $(id) {
    return document.getElementById(id);
}
function showleftmenu(num){
    for (var i = 0; i < 3; i++) {
        $("help_center_leftmenu" + i).className = "";
        $("menu_content" + i).style.display = "none";
    }
    $("help_center_leftmenu" + num).className = "active";
    $("menu_content" + num).style.display = "block";
    SetCookie("flag", num);
}
function initfn() {
    if (getCookie('flag')) {
        var n = getCookie('flag');
        for (var i = 0; i < 3; i++) {
            $("help_center_leftmenu" + i).className = "";
            $("menu_content" + i).style.display = "none";
        }
        $("help_center_leftmenu" + n).className = "active";
        $("menu_content" + n).style.display = "block";
    }
}     

 
function showmenuitem(thisid){
     var items=document.getElementById("help_categories").getElementsByTagName("a");
    for(var i=0;i<items.length;i++){
        if(items[i].className=="style"){
            items[i].className="";
        }
    }
    thisid.className="style";
}
//写cookies函数
function SetCookie(name,value)//两个参数,一个是cookie的名子,一个是值
{
    var Days = 30; //此 cookie 将被保存 30 天
    var exp  = new Date();    //new Date("December 31, 9998");
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getCookie(name)//取cookies函数      
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr != null) return unescape(arr[2]); return null;

}
function delCookie(name)//删除cookie
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}


</script>



<script language="javascript">

///点击链接,首先记录cookie,然后跳转
function change_bg(thisA, num) {

 writeCookie('nav', num, 1);//写入cookie值,以便在另一页面调用,有效1分钟内
}

///页面载入后需自动执行的函数
function loadFN(){

 navA = document.getElementById("nav").getElementsByTagName("a");

 navCookie = readCookie('nav');

 if(navCookie) {
  for(key in navA) {
   navA[key].className = '';
  }
  navA[navCookie].className = 'current';

 }
}
///页面载入后执行js的loadFN函数
window.onload = loadFN;

///页面关闭时清除导航相关的cookie
//window.onunload = clearNavCookie;

///写入cookie值
function writeCookie(name, value, fens) {
  var expire = "";
  if(fens != null)
  {
    expire = new Date((new Date()).getTime() + fens * 60000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}

///读取名为name的cookie值
function readCookie(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;
}

///清除命名为cookieName的cookie
function clearNavCookie() {

 writeCookie('nav', null, 0);
}
</script>

</head>
<body  onload="initfn()">
<div id="box">
  <div id="header">
   
    <div id="h_nav">
      <div class="nav" id="nav">
  <ul>
    <li><a  href="file:///E:/先成管理系统/客户中心——列表1.html" class="current" onmousedown="change_bg(this, 0)">工作台</a></li>
    <li><a  href="file:///E:/先成管理系统/客户中心——列表1.html" onmousedown="change_bg(this, 1)">日程    </a> </li>
    <li><a  href="file:///E:/先成管理系统/客户中心——列表1.html" onmousedown="change_bg(this, 2)">任务中心</a> </li>
    <li><a  href="file:///E:/先成管理系统/客户中心——列表1.html" onmousedown="change_bg(this, 3)">我的任务(代办)</a> </li>
    <li><a  href="file:///E:/先成管理系统/客户中心——列表1.html" onmousedown="change_bg(this, 4)">客户中心</a> </li>


  
  </ul>
</div>
    </div>
    <div id="btn">
      <ul>
        <li><a href=""><img src="images/xc_12.gif" style="margin-left:5px;" /></a> <a href=""><img src="images/xc_14.gif" /></a></li>
        <li><a href=""><img src="images/xc_16.gif" style="margin-left:5px;"  /></a> <a href=""><img src="images/xc_18.gif" /></a></li>
        <li style=" border-right:none;"><a href=""><img src="images/xc_20.gif" style="margin-left:5px;"  /></a> <a href=""><img src="images/xc_22.gif" /></a></li>
      </ul>
    </div>
  </div>
  <div id="center">
    <div id="c_left">
<div id="help_categories">
        <div class="classification">
       
          <div class="set_up">
            <h3 id="help_center_leftmenu1"><a href="#" style="cursor:hand" onmousedown="showleftmenu(1)">项目浏览</a></h3>
            <ul id="menu_content1" style="display:none;">
          
            </ul>
          </div>
          <div class="set_up" style="margin-top:3px;">
            <h3 id="help_center_leftmenu2"><a href="#" style="cursor:hand" onmousedown="showleftmenu(2)">查询项目</a></h3>
            <ul id="menu_content2" style="display:none;">
          
            </ul>
          </div>
          <div class="set_up" style="margin-top:3px;">
            <h3 id="help_center_leftmenu0" class="active"><a style="cursor:hand" onmousedown="showleftmenu(0)">项目汇总</a></h3>
            <ul id="menu_content0">
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer" >·标志设计</a></li>
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer">·VI设计</a></li>
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer">·包装设计</a></li>
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer">·网站设计</a></li>
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer">·空间设计</a></li>
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer">·导示设计</a></li>
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer">·工业设计</a></li>
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer">·品牌顾问</a></li>
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer">·品牌命名</a></li>
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer">·广告设计</a></li>
              <li><a onclick="showmenuitem(this)" style=" cursor:pointer">·传媒设计</a></li>
            </ul>
          </div>
        </div>
      </div>
    </div>
   
  </div>
  <div id="foot">
    <p>&nbsp;&nbsp;版权所有:</p>
    先成设计www.
2010-08-12 14:00
foktime
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:奥斯维辛
等 级:贵宾
威 望:35
帖 子:795
专家分:2742
注 册:2009-9-4
收藏
得分:0 
怎么又弄了一套操作cookie的方法
这个也是想实现页签切换吗?横的竖的不都是一个原理么
2010-08-12 15:16
liweilkm
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2010-8-11
收藏
得分:0 
回复 14楼 foktime
用你的那个做了下但是刷新就变了!所以再找了套!但是按钮不变了。还是你的强大点。
2010-08-12 17:20
foktime
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:奥斯维辛
等 级:贵宾
威 望:35
帖 子:795
专家分:2742
注 册:2009-9-4
收藏
得分:0 
仔细研究代码
你找10套都是一样的  对cookie的操作方法不会有变 只是写法不同
2010-08-12 17:36
快速回复:JS问题很急,请各位看下。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026906 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved