<script type="text/javascript">
cookieName = "TraderId";
domainName = "localhost";
prefix = "";
bgColor = "FEEEE0";
var categoryId = 0101067;
var c = getCookie("categoryId");
if (c == null || c == "null" ){
addCookie("categoryId",categoryId);
if (categoryId !=null && categoryId!=""){
clearCookie(cookieName);
}
}else if(c !=categoryId){
clearCookie("categoryId");
clearCookie(cookieName);
}
function addCookie(name,value) {
value = value+prefix;
if(categoryId =="")
return;
document.cookie = name + "=" + value +";path=/;"+ "domain="+domainName;;
}
function clearCookie(name) {
var value = "null";
cookieValue= name + "=" + value + ";path=/;" + "domain="+domainName;
document.cookie = cookieValue;
}
function addOfferId(arg) {
arg = arg + prefix;
if(hasOfferId(arg)) {
return;
}
if(arg == "") {
return;
}
value = getCookie(cookieName);
if(value == null || value == "null" ) {
value = arg ;
} else {
value=value+","+ arg;
}
cookieValue = cookieName + "=" + value + ";path=/;" + "domain="+domainName;
document.cookie = cookieValue;
//alert(document.cookie);
} function delOfferId(arg) {
arg = arg + prefix; if(!hasOfferId(arg)) {
alert("要删除的商机不存在");
return;
} value = getCookie(cookieName);
var offerIds = stringToArray(value);
var len = offerIds.length;
var result = "";
var counter = 0;
for(var i=0;i<len;i++) {
if(offerIds[i] != arg) {
if(counter == 0) {
result = offerIds[i];
} else {
result = result + "," + offerIds[i];
}
counter++;
}
}
cookieValue = cookieName + "=" + result + ";path=/;" + "domain="+domainName;
document.cookie = cookieValue;
}
function getCookie(name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i=0;
while(i<clen) {
var j=i+alen;
if(document.cookie.substring(i,j)==arg)
return www_helpor_net(j);
i=document.cookie.indexOf(" ",i)+1;if(i==0)
break;
}
return null;
} function www_helpor_net(offset) {
var endstr=document.cookie.indexOf(";",offset);
if(endstr==-1)
endstr=document.cookie.length;
return unescape(document.cookie.substring(offset,endstr));
} function hasOfferId(arg) {
var value = getCookie(cookieName);
if(value == null || value == "null" || value.indexOf(arg) == -1 ) {
return false;
} else {
return true;
}
} function getOfferIdCount() { value = getCookie(cookieName);
if(value == null || value == 'null') {
return 0;
}
var count = 1;
while(value.indexOf(",") != -1) {
var position = value.indexOf(",");
var len = value.length;
value = value.substring(position+1,len);
count++;
}
return count;
}
function stringToArray(str) {
var temp = str;
var strArray = new Array();
var count = 0;
while(temp.indexOf(",") != -1) { var position = temp.indexOf(",");
strArray[count] = temp.substring(0,position);
//alert( strArray[count] );
count++;
var len = temp.length;
temp = temp.substring(position+1,len); }
strArray[count] = temp;
//alert(strArray[count]);
return strArray;
}
function clickcompareBox(id,box) {
if(box.checked){
if(getOfferIdCount()>=6){
alert('您已经选择了6条信息,同时可以对比的信息不能超过6个');
box.checked=false;
}else{
addOfferId(id);
var countId = box.id.substring("compareBox".length,box.id.length);
var trTag = document.getElementById("compareColor"+countId);
trTag.style.background=bgColor;
}
} else {
delOfferId(id);
var countId = box.id.substring("compareBox".length,box.id.length);
var trTag = document.getElementById("compareColor"+countId);
if(countId%2!= 0){
trTag.style.background="ffffff";
}else{
trTag.style.background="F6F6F6";
}
}
}
function doCompare(){
if(getOfferIdCount()<=1){
alert('请至少选择2条信息进行对比!');
}else{
window.open('{$Tatty_WebUrl}/Trader/Trader_Compare.Asp');
}
}
function cleanCookie() {
if(confirm("您确认执行清空操作吗?")){
var value = "null";
cookieValue= cookieName + "=" + value + ";path=/;" + "domain="+domainName;
document.cookie = cookieValue;
for(var i=1;i<=10;i++){
var elem = document.getElementById("compareBox"+i);
if(elem != null && elem.checked){
elem.checked = false;
elem = document.getElementById("compareColor"+i);
if(i%2 != 0){
elem.style.background="ffffff";
}else{
elem.style.background="F6F6F6";
}
}
}
}
}
;
for(var i = 1;i < 11 ;i++){
var cpbox = document.getElementById("compareBox"+i);
var cpcolor = document.getElementById("compareColor"+i);
if(cpbox!= null){
if(hasOfferId(cpbox.name)){
cpbox.checked = true;
if(cpcolor != null){
cpcolor.style.background= bgColor;
}
}else{
cpbox.checked = false;
}
}
}
</script>
请帮我看看,为什么不能添加Cookies。。
http://list.china.alibaba.com/buyer/offerlist/14-141907.html
具体地址可以看这里,我直接把他的代码全部复制了保存到本地,也不行。。可郁闷呢
cookieName = "TraderId";
domainName = "localhost";
prefix = "";
bgColor = "FEEEE0";
var categoryId = 0101067;
var c = getCookie("categoryId");
if (c == null || c == "null" ){
addCookie("categoryId",categoryId);
if (categoryId !=null && categoryId!=""){
clearCookie(cookieName);
}
}else if(c !=categoryId){
clearCookie("categoryId");
clearCookie(cookieName);
}
function addCookie(name,value) {
value = value+prefix;
if(categoryId =="")
return;
document.cookie = name + "=" + value +";path=/;"+ "domain="+domainName;;
}
function clearCookie(name) {
var value = "null";
cookieValue= name + "=" + value + ";path=/;" + "domain="+domainName;
document.cookie = cookieValue;
}
function addOfferId(arg) {
arg = arg + prefix;
if(hasOfferId(arg)) {
return;
}
if(arg == "") {
return;
}
value = getCookie(cookieName);
if(value == null || value == "null" ) {
value = arg ;
} else {
value=value+","+ arg;
}
cookieValue = cookieName + "=" + value + ";path=/;" + "domain="+domainName;
document.cookie = cookieValue;
//alert(document.cookie);
} function delOfferId(arg) {
arg = arg + prefix; if(!hasOfferId(arg)) {
alert("要删除的商机不存在");
return;
} value = getCookie(cookieName);
var offerIds = stringToArray(value);
var len = offerIds.length;
var result = "";
var counter = 0;
for(var i=0;i<len;i++) {
if(offerIds[i] != arg) {
if(counter == 0) {
result = offerIds[i];
} else {
result = result + "," + offerIds[i];
}
counter++;
}
}
cookieValue = cookieName + "=" + result + ";path=/;" + "domain="+domainName;
document.cookie = cookieValue;
}
function getCookie(name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i=0;
while(i<clen) {
var j=i+alen;
if(document.cookie.substring(i,j)==arg)
return www_helpor_net(j);
i=document.cookie.indexOf(" ",i)+1;if(i==0)
break;
}
return null;
} function www_helpor_net(offset) {
var endstr=document.cookie.indexOf(";",offset);
if(endstr==-1)
endstr=document.cookie.length;
return unescape(document.cookie.substring(offset,endstr));
} function hasOfferId(arg) {
var value = getCookie(cookieName);
if(value == null || value == "null" || value.indexOf(arg) == -1 ) {
return false;
} else {
return true;
}
} function getOfferIdCount() { value = getCookie(cookieName);
if(value == null || value == 'null') {
return 0;
}
var count = 1;
while(value.indexOf(",") != -1) {
var position = value.indexOf(",");
var len = value.length;
value = value.substring(position+1,len);
count++;
}
return count;
}
function stringToArray(str) {
var temp = str;
var strArray = new Array();
var count = 0;
while(temp.indexOf(",") != -1) { var position = temp.indexOf(",");
strArray[count] = temp.substring(0,position);
//alert( strArray[count] );
count++;
var len = temp.length;
temp = temp.substring(position+1,len); }
strArray[count] = temp;
//alert(strArray[count]);
return strArray;
}
function clickcompareBox(id,box) {
if(box.checked){
if(getOfferIdCount()>=6){
alert('您已经选择了6条信息,同时可以对比的信息不能超过6个');
box.checked=false;
}else{
addOfferId(id);
var countId = box.id.substring("compareBox".length,box.id.length);
var trTag = document.getElementById("compareColor"+countId);
trTag.style.background=bgColor;
}
} else {
delOfferId(id);
var countId = box.id.substring("compareBox".length,box.id.length);
var trTag = document.getElementById("compareColor"+countId);
if(countId%2!= 0){
trTag.style.background="ffffff";
}else{
trTag.style.background="F6F6F6";
}
}
}
function doCompare(){
if(getOfferIdCount()<=1){
alert('请至少选择2条信息进行对比!');
}else{
window.open('{$Tatty_WebUrl}/Trader/Trader_Compare.Asp');
}
}
function cleanCookie() {
if(confirm("您确认执行清空操作吗?")){
var value = "null";
cookieValue= cookieName + "=" + value + ";path=/;" + "domain="+domainName;
document.cookie = cookieValue;
for(var i=1;i<=10;i++){
var elem = document.getElementById("compareBox"+i);
if(elem != null && elem.checked){
elem.checked = false;
elem = document.getElementById("compareColor"+i);
if(i%2 != 0){
elem.style.background="ffffff";
}else{
elem.style.background="F6F6F6";
}
}
}
}
}
;
for(var i = 1;i < 11 ;i++){
var cpbox = document.getElementById("compareBox"+i);
var cpcolor = document.getElementById("compareColor"+i);
if(cpbox!= null){
if(hasOfferId(cpbox.name)){
cpbox.checked = true;
if(cpcolor != null){
cpcolor.style.background= bgColor;
}
}else{
cpbox.checked = false;
}
}
}
</script>
请帮我看看,为什么不能添加Cookies。。
http://list.china.alibaba.com/buyer/offerlist/14-141907.html
具体地址可以看这里,我直接把他的代码全部复制了保存到本地,也不行。。可郁闷呢
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货