请JavaScript或cookie高手修改一段代码!
  • 收藏任务 (1)
  • 订阅任务

当前任务已有:1427人关注 8人报名 9个稿件 0篇交流  备选稿件(0)个  橱窗方式浏览 

稿件编号:1926122号    参加猪八戒礼品游戏之捉迷藏,免费礼品等你拿!
  • MICKEYSKY VIP会员
  • 等 级:猪一戒
  • 信用值:
  • 能力值:
发布者已浏览查看所有交稿 时间:2008/05/16 10:37:35 评论:5票数:8 下载附件 

  

严格按照你的要求编写

请查看附件

代码如下:

汗 咋贴不了代码 还是看附件吧

谢咯

  
客户点评
  • “如果能写成这样一种格式那就更好”只是如果,没有要求“一定要”。因为我对脚本不熟悉,测试后觉得能写成这样我更易掌控。难度大的话就不要了。  (tongdi点评于2008-05-16 21:00:54)
  • 奇怪,不能贴代码。把换成()试试。 如果能写成这样一种格式那就更好(就是把DIV写在脚本之外): (SCRIPT language=\"JavaScript\" src=\"cookie.js\")(/SCRIPT) (div)关闭此项(/div) (div)开启此项(/div)   (tongdi点评于2008-05-16 18:34:36)
  • 非常感谢!代码基本实现了我的意图,代码感觉也较为精练简短。可能我的表达不是很清楚,请再稍为修改一下:页面打开后上面有二项,一是“关闭此项”,一是“开启此项”。“开启此项”要求始终保留在页面。如果能写成这样一种格式那就更好(就是把DIV写在脚本之外): 关闭此项 开启此项  (tongdi点评于2008-05-16 18:30:16)
稿件编号:1925989号    参加猪八戒礼品游戏之捉迷藏,免费礼品等你拿!
  • metyou2004 爱心威客 VIP会员
  • 等 级:猪五戒
  • 信用值:
  • 能力值:
发布者已浏览查看所有交稿 时间:2008/05/16 09:32:06 评论:1票数:5   

不知道我理解的对不对,请看一下代码再说:

<script>
function setCookies(cookieName,cookieValue,expirehours)
{
var today = new Date();
var expire = new Date();
expire.setTime(today.getTime() + 3600000 * 365 * 24);
document.cookie = cookieName+'='+escape(cookieValue)+ ';expires='+expire.toGMTString() + "; path=/;";
}

function ReadCookies(cookieName)
{
var theCookie=''+document.cookie;
var ind=theCookie.indexOf(cookieName);
if (ind==-1 || cookieName=='') return '';
var ind1=theCookie.indexOf(';',ind);
if (ind1==-1) ind1 = theCookie.length;
return unescape(theCookie.substring(ind+cookieName.length+1,ind1)).replace(";","");
}

function closeBox(a,b)
{
    var elm = document.getElementById('wordreplacerBox');
    if (elm) { elm.style.display = 'none'; }
    setCookies(a,b);
}
if(ReadCookies("001") != "close")
{
document.writeln("<div id='wordreplacerBox'><a title=点击关闭 href=javascript:closeBox('001','close')>关闭此项</a></div>");
}
else
{
document.writeln("<div id='gg'><a title=点击关闭 href=javascript:closeBox('001','open')>删除</a></div>");
}
</script>

  
客户点评
  • 感谢,不过效果有偏差。  (tongdi点评于2008-05-16 18:51:58)
稿件编号:1926096号    参加猪八戒礼品游戏之捉迷藏,免费礼品等你拿!
  • 沃客吧
  • 等 级:猪二戒
  • 信用值:
  • 能力值:
发布者已浏览查看所有交稿 时间:2008/05/16 10:23:52 评论:0票数:6   

<script>
function setCookies(cookieName,cookieValue,expirehours){
var today = new Date();
var expire = new Date();
expire.setTime(today.getTime() + 3600000 * 365 * 24);
document.cookie = cookieName+'='+escape(cookieValue)+ ';expires='+expire.toGMTString() + "; path=/;";
}
function ReadCookies(cookieName){
var theCookie=''+document.cookie;
var ind=theCookie.indexOf(cookieName);
if (ind==-1 || cookieName=='') return '';
var ind1=theCookie.indexOf(';',ind);
if (ind1==-1) ind1 = theCookie.length;
return unescape(theCookie.substring(ind+cookieName.length+1,ind1)).replace(";","");
}

function closeBox()
{
    var elm = document.getElementById('wordreplacerBox');
    if (elm) { elm.style.display = 'none'; }

    elm = document.getElementById('wordreplacerBox_del');
    if (elm) { elm.style.display = ''; }

    setCookies("001","close");
}

function openBox()
{
    var elm = document.getElementById('wordreplacerBox_del');
    if (elm) { elm.style.display = 'none'; }

    elm = document.getElementById('wordreplacerBox');
    if (elm) { elm.style.display = ''; }

    setCookies("001","");
}


if(ReadCookies("001") != "close"){
  document.writeln("<div id='wordreplacerBox'><a title=点击关闭 href='javascript:closeBox()'>关闭此项</a></div>");
  document.writeln("<div id='wordreplacerBox_del' style='display:none'><a title=点击删除 href='javascript:openBox()'>删除并还原“关闭此项”</a></div>");
}
else
{
 document.writeln("<div id='wordreplacerBox' style='display:none'><a title=点击关闭 href='javascript:closeBox()'>关闭此项</a></div>");
 document.writeln("<div id='wordreplacerBox_del'><a title=点击删除 href='javascript:openBox()'>删除并还原“关闭此项”</a></div>");
}

</script>

  
稿件编号:1926361号    
  • 五龙山 爱心威客 VIP会员
  • 等 级:猪六戒
  • 信用值:
  • 能力值:
发布者已浏览查看所有交稿 时间:2008/05/16 12:41:41 评论:1票数:2   价格太高了 用不了这么多钱  
客户点评
  • 知识无价,可惜我出不起更多。  (tongdi点评于2008-05-16 18:48:08)
稿件编号:1926506号    
  • ban101 爱心威客
  • 等 级:猪四戒
  • 信用值:
  • 能力值:
发布者已浏览查看所有交稿 时间:2008/05/16 13:40:54 评论:0票数:1   够难的,过来支持一下……  
稿件编号:1926724号    
  • xxch229 爱心威客 VIP会员
  • 等 级:猪四戒
  • 信用值:
  • 能力值:
发布者已浏览查看所有交稿 时间:2008/05/16 14:47:36 评论:4票数:1   

 

 

 

 

 

重在参与

 

 

<script type="text/javascript">
function setCookies(cookieName,cookieValue,expirehours){
var today = new Date();
var expire = new Date();
expire.setTime(today.getTime() + 3600000 * 365 * 24);
document.cookie = cookieName+'='+escape(cookieValue)+ ';expires='+expire.toGMTString() + "; path=/;";
}
function ReadCookies(cookieName){
var theCookie=''+document.cookie;
var ind=theCookie.indexOf(cookieName);
if (ind==-1 || cookieName=='') return '';
var ind1=theCookie.indexOf(';',ind);
if (ind1==-1) ind1 = theCookie.length;
return unescape(theCookie.substring(ind+cookieName.length+1,ind1)).replace(";","");
}

function closeBox()
{
 //设置关闭链接的div不显示
    var elm = document.getElementById('wordreplacerBox');
    if (elm) { elm.style.display = 'none'; }
//新增判断实时显示删除链接的div
    elm = document.getElementById('wordreplacerBox_del');
    if (elm) { elm.style.display = ''; }
//给cookie赋标志
    setCookies("001","close");
}

function openBox()//新增一个方法给删除操作调用
{
 //设置删除链接的div不显示
    var elm = document.getElementById('wordreplacerBox_del');
    if (elm) { elm.style.display = 'none'; }
//新增判断实时显示原关闭链接的div
    elm = document.getElementById('wordreplacerBox');
    if (elm) { elm.style.display = ''; }
//清除cookie的值
    setCookies("001","");
}


if(ReadCookies("001") != "close"){
  document.writeln("<div id='wordreplacerBox'><a title=点击关闭 href='javascript:closeBox()'>关闭此项</a></div>");
  document.writeln("<div id='wordreplacerBox_del' style='display:none'><a title=点击删除 href='javascript:openBox()'>删除并还原“关闭此项”</a></div>");
}
else
{
 document.writeln("<div id='wordreplacerBox' style='display:none'><a title=点击关闭 href='javascript:closeBox()'>关闭此项</a></div>");
 document.writeln("<div id='wordreplacerBox_del'><a title=点击删除 href='javascript:openBox()'>删除并还原“关闭此项”</a></div>");
}

</script>

  
客户点评
  • 非常感谢这种“重在参与”的精神,个人认为这种精神如果能用在5.12的捐款捐血中去效果更好,呵呵。  (tongdi点评于2008-05-16 18:45:46)
稿件编号:1926118号    
  • 沃客吧
  • 等 级:猪二戒
  • 信用值:
  • 能力值:
发布者已浏览查看所有交稿 时间:2008/05/16 10:35:30 评论:4票数:8   

对不起,忘记说明一下代码的修改了,新增一个div和一个openBox方法,可以实时显示两个状态的交替情况,刷新后也会保持状态。

<script type="text/javascript">
function setCookies(cookieName,cookieValue,expirehours){
var today = new Date();
var expire = new Date();
expire.setTime(today.getTime() + 3600000 * 365 * 24);
document.cookie = cookieName+'='+escape(cookieValue)+ ';expires='+expire.toGMTString() + "; path=/;";
}
function ReadCookies(cookieName){
var theCookie=''+document.cookie;
var ind=theCookie.indexOf(cookieName);
if (ind==-1 || cookieName=='') return '';
var ind1=theCookie.indexOf(';',ind);
if (ind1==-1) ind1 = theCookie.length;
return unescape(theCookie.substring(ind+cookieName.length+1,ind1)).replace(";","");
}

function closeBox()
{
 //设置关闭链接的div不显示
    var elm = document.getElementById('wordreplacerBox');
    if (elm) { elm.style.display = 'none'; }
//新增判断实时显示删除链接的div
    elm = document.getElementById('wordreplacerBox_del');
    if (elm) { elm.style.display = ''; }
//给cookie赋标志
    setCookies("001","close");
}

function openBox()//新增一个方法给删除操作调用
{
 //设置删除链接的div不显示
    var elm = document.getElementById('wordreplacerBox_del');
    if (elm) { elm.style.display = 'none'; }
//新增判断实时显示原关闭链接的div
    elm = document.getElementById('wordreplacerBox');
    if (elm) { elm.style.display = ''; }
//清除cookie的值
    setCookies("001","");
}


if(ReadCookies("001") != "close"){
  document.writeln("<div id='wordreplacerBox'><a title=点击关闭 href='javascript:closeBox()'>关闭此项</a></div>");
  document.writeln("<div id='wordreplacerBox_del' style='display:none'><a title=点击删除 href='javascript:openBox()'>删除并还原“关闭此项”</a></div>");
}
else
{
 document.writeln("<div id='wordreplacerBox' style='display:none'><a title=点击关闭 href='javascript:closeBox()'>关闭此项</a></div>");
 document.writeln("<div id='wordreplacerBox_del'><a title=点击删除 href='javascript:openBox()'>删除并还原“关闭此项”</a></div>");
}

</script>

 

  
客户点评
  • “如果能写成这样一种格式那就更好”只是如果,没有要求“一定要”。因为我对脚本不熟悉,测试后觉得能写成这样我更易掌控。难度大的话就不要了。  (tongdi点评于2008-05-16 21:01:21)
  • 奇怪,不能贴代码。把换成()试试。如果能写成这样一种格式那就更好(就是把DIV写在脚本之外): (SCRIPT language=\"JavaScript\" src=\"cookie.js\")(/SCRIPT) (div)关闭此项(/div) (div)开启此项(/div)  (tongdi点评于2008-05-16 18:43:37)
  • 非常感谢!代码接近了我的意图,可能我的表达不是很清楚,可参考楼上的效果并请再稍为修改一下:页面打开后上面有二项,一是“关闭此项”,一是“还原”。点击“关闭此项”后页面只剩下“还原”。而当点击“还原”后页面又恢复以上两项。如果能写成这样一种格式那就更好(就是把DIV写在脚本之外): 关闭此项 开启此项  (tongdi点评于2008-05-16 18:43:06)
稿件编号:1927462号    
  • xxch229 爱心威客 VIP会员
  • 等 级:猪四戒
  • 信用值:
  • 能力值:
发布者已浏览查看所有交稿 时间:2008/05/16 19:55:34 评论:0票数:1   

靠,我只是随便弄了一下,你们又不是不知道这个网站的规矩,如果相同的帖子,谁发的早谁的有效,你们别得理不饶人,好不好,有那闲工夫在这说我,还不如去灾区救人呢

你有什么了不起啊,把我提交的任务给删了,就行了呗,还在这瞎说啥,能了是不啊?

  
稿件编号:1927465号    
  • xxch229 爱心威客 VIP会员
  • 等 级:猪四戒
  • 信用值:
  • 能力值:
发布者已浏览查看所有交稿 时间:2008/05/16 19:56:28 评论:0票数:1   

切,一个一个的还没完没了啦啊?真恶心