Page is a not externally linkable
mbennie - 1:38 pm on Sep 7, 2007 (gmt 0)
Any idea how to have it display custom anchor text? <html> // basic get and set functions for javascript cookies function getCookie (cookieName) { // custom code to store and remove links from the cookies function storePage(){ // if url not already in cookie, then add it here //refresh screen after link has been added function removePage(url){ // get the cookie expiry date // code to write the list of urls to the page, and extra link to remove the url from the list. </script> <body> <p> </body>
I found some code on another site that works great.
<script>
function setCookie (cookieName, cookieValue, expires, path, domain, secure) {
document.cookie =
escape(cookieName) + '=' + escape(cookieValue)
+ (expires? '; EXPIRES=' + expires.toGMTString() : '')
+ (path? '; PATH=' + path : '')
+ (domain? '; DOMAIN=' + domain : '')
+ (secure? '; SECURE' : '');
}
var cookieValue = null;
var posName = document.cookie.indexOf(escape(cookieName) + '=');
if (posName!= -1) {
var posValue = posName + (escape(cookieName) + '=').length;
var endPos = document.cookie.indexOf(';', posValue);
if (endPos!= -1) {
cookieValue = unescape(document.cookie.substring(posValue, endPos));
} else {
cookieValue = unescape(document.cookie.substring(posValue));
}
}
return cookieValue;
}
thisPage = document.location.href;
var pageList = getCookie("pageList");
// check to see whether this url is already in the cookie's links list
var linkFound = false;
if (pageList!= "" && pageList!= null) {
pSplit = pageList.split(";");
for (a=0;a<pSplit.length;a++) {
if (pSplit[a] == thisPage) linkFound = true;
}
}
if (!linkFound) {
if (pageList == null ¦¦ pageList == ";") {
pageList = thisPage
} else {
pageList += ";" + thisPage;
}
}
// make the cookie expire in 1 years time:
var now = new Date();
var nextYear = new Date(now.getTime() + 1000 * 60 * 60 * 24 * 365);
setCookie("pageList",pageList,nextYear);
window.location.reload();
}
var pageList = getCookie("pageList");
var linkList = ""
// add each link to the linksList string and skip the one you want to remove
if (pageList!= "" && pageList!= null) {
pSplit = pageList.split(";");
for (a=0;a<pSplit.length;a++) {
if (pSplit[a]!= url && pSplit[a]!= '') linkList += ";" + pSplit[a];
}
}
var now = new Date();
var nextYear = new Date(now.getTime() + 1000 * 60 * 60 * 24 * 365);
setCookie("pageList",linkList,nextYear);
// refresh screen after link has been removed
window.location.reload();
}
function writeLinks(){
var pageList = getCookie("pageList")
if (pageList!= "" && pageList!= null) {
pSplit = pageList.split(";")
for (a=0;a<pSplit.length;a++) {
if (pSplit[a]!= '' && pSplit[a]!= 'null') {
document.write('<a href="' + pSplit[a] + '">' + pSplit[a] + '</a> <a href="javascript:removePage(\'' + pSplit[a] + '\')">[remove link]</a><br>');
}
}
} else {
document.write("There are no articles saved.");
}
}
<a href="javascript:storePage()">Store this page</a>
Your current links list is:<br>
<script>
writeLinks();
</script>
</html>