Slet kun 1 genvej?
Jeg har hentet dette script: http://www.findmysoft.com/scripts/Stored-Documents-download.htmlDet går ud på at man kan gemme sider som genveje - det fungerer helt fint, men man kan ikke kun slette 1 genvej af gangen, men man skal slette alle genveje på en gang, det holder ik helt, da det jo kan være at man gerne vil beholde andre genveje...
Hvordan kan jeg fikse det sådan at man kan det?
Javascript koden ser sådanne ud:
var expDays= 365;
var CookieInfoStr='';
var expdate = new Date();
var olddate = new Date();
expdate.setTime (expdate.getTime() + (expDays*24*60*60*1000));
olddate.setTime (expdate.getTime());
function StoreDocumentLink(){
linktext = "Tilføj genvej";
document.write ('<a href="java script:addCookieArray(\'' + document.title + '\',\'' + location.href + '\');">'+linktext+'</a><br>');
}
function ClearStoredDocumentsLink(){
document.write ('<a href="java script:del();">Clear all documents</a><br>');
}
function ShowStoredDocumentsLink(){
var i = 0;
//document.write ('<ul>');
while (getCookie('names' + i) != null) {
document.write ('<img src="/files/Diverse/bullit_red_8.gif" alt="" title="" /> <a href="' + getCookie('urls' + i) + '">' + getCookie('names' + i) + '</a>' );
document.write ('<br>');
i++;
}
if (i==0){
document.write ('Du har ikke tilføjet nogle genveje' );
document.write ('<br>');
}
//document.write ('</ul>');
}
function getCookie (name) {
var dcookie = document.cookie;
var cname = name + "=";
var clen = dcookie.length;
var cbegin = 0;
while (cbegin < clen) {
var vbegin = cbegin + cname.length;
if (dcookie.substring(cbegin, vbegin) == cname) {
var vend = dcookie.indexOf (";", vbegin);
if (vend == -1) vend = clen;
return unescape(dcookie.substring(vbegin, vend));
}
cbegin = dcookie.indexOf(" ", cbegin) + 1;
if (cbegin == 0) break;
}
return null;
}
function setCookie (name, value, expires) {
if (!expires) expires = new Date();
document.cookie=name+"="+escape (value)+"; expires="+expires.toGMTString()+"; path=/";
}
function setCookieArray(name){
this.length = setCookieArray.arguments.length - 1;
for (var i = 0; i < this.length; i++) {
this[i + 1] = setCookieArray.arguments[i + 1];
setCookie (name + i, this[i + 1], expdate);
}
}
function addCookieArray(name, val){
var i = 0;
var found=false;
while (getCookie('names' + i) != null) {
if (getCookie('names' + i) == name) found=true;
i++;
}
if (!found) {
setCookie ('names' + i, name, expdate);
setCookie ('urls' + i, val, expdate);
location.reload();
}
else {
//alert('This page has been added to your stored documents. ');
}
}
function getCookieArray(name){
var i = 0;
while (getCookie(name + i) != null) {
this[i + 1] = getCookie(name + i);
i++; this.length = i;
}
}
function del() {
var i = 0;
if (window.confirm('Clear all stored documents? ')) {
while (getCookie('names' + i) != null) {
setCookie ('names' + i, '', olddate);
setCookie ('urls' + i, '', olddate);
i++;
}
i++;
setCookie ('names' + i, '', olddate);
setCookie ('urls' + i, '', olddate);
//alert('Stored documents have been cleared. ');
location.reload();
}
}