请JavaScript或cookie高手修改一段代码! 收缩此栏目
-
中标稿件:
会员MICKEYSKY的1926122号稿 件[2008-12-05 11:20:11] 投票时时彩
中标模式单人中标模式,一人独享赏金。
赏金申明本站已经收到客户的汇款,确定此任务总金额的80%可以支付 给被客户选中的会员。
版权声明稿件如果被客户选中,在完成赏金支付后,该作品的全部知识产权自动转移给客户;如果没有被选中,可自行处理。
当前任务已有:1427人关注 8人报名 9个稿件 0篇交流 备选稿件(0)个 橱窗方式浏览
- MICKEYSKY
- 等 级:猪一戒
- 信用值:

- 能力值:


下载附件 严格按照你的要求编写
请查看附件
代码如下:
汗 咋贴不了代码 还是看附件吧
谢咯
客户点评
- “如果能写成这样一种格式那就更好”只是如果,没有要求“一定要”。因为我对脚本不熟悉,测试后觉得能写成这样我更易掌控。难度大的话就不要了。 (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)
- metyou2004
- 等 级:猪五戒
- 信用值:


- 能力值:

不知道我理解的对不对,请看一下代码再说:
<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)
- 沃客吧
- 等 级:猪二戒
- 信用值:



- 能力值:


<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>
- xxch229
- 等 级:猪四戒
- 信用值:


- 能力值:



重在参与
<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)
- 沃客吧
- 等 级:猪二戒
- 信用值:



- 能力值:


对不起,忘记说明一下代码的修改了,新增一个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)




