Hvorfor skriver den intet i tabellen?
Har et script der skulle gemme min titel i en td - fungerer som en slags "personlige genveje" - Se evt http://www.inet-design.dk/idd24.asp hvor jeg har fundet det.Har prøvet at tilpasse, men kan ik rigtig få det til at spille...
Min JS:
/**************************/
/**** COOKIE FUNCTIONS ****/
var cookie_domain = window.location.hostname;
function createCookie(name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires=" + date.toGMTString();
}
else var expires = "";
value = escape(value);
document.cookie = name + "=" + value + expires + ";domain=" + cookie_domain + ";path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name,"",-1);
}
/**** COOKIE FUNCTIONS ****/
/**************************/
/****************************/
/**** BOOKMARK FUNCTIONS ****/
var bookmarkCookieId = "bm";
function delBookmark(id) {
if (ua['dom']) {
var bmArr = readBookmarkCookie();
var res = '';
if (bmArr != null) {
for (var i = 0; i < bmArr.length; i++) {
if (bmArr[i] != id) {
if ((bmArr[i] != '') && (bmArr[i] != null)) {
res += bmArr[i] + 'x';
}
}
}
}
var oDiv = document.getElementById('abl_list');
var aTable = oDiv.getElementsByTagName('table');
var oTable = aTable[0];
var oTBODY = oTable.tBodies.item(0);
for (var i = 0; i < oTBODY.rows.length; i++) {
var oTR = oTBODY.rows.item(i);
if (oTR.id == 'bm_' + id) {
oTBODY.deleteRow(i);
i = oTBODY.rows.length;
}
}
if (res == '') {
eraseCookie(bookmarkCookieId);
}
else {
setBookmarkCookie(res);
}
}
return false;
}
function addBookmark() {
var aTitle = document.getElementsByTagName('title');
var oTitle = null;
if (aTitle.length > 0) {
oTitle = aTitle[0].innerHTML;
}
var tRx = /^.*-\s(.+)$/i;
if (oTitle.match(tRx)) {
oTitle = oTitle.replace(tRx, "$1");
}
var oVal = null;
var loc = window.location.pathname;
if (loc.length > 1) {
loc = loc.substr(1, loc.length - 1);
}
//alert(oTitle);
//alert(loc);
if (oVal == null) {
var itemFound = false;
var bmArr = readBookmarkCookie();
var cStr = '';
if (bmArr != null) {
for (var i = 0; i < bmArr.length; i++) {
if ((bmArr[i] != null) && (bmArr[i] != '')) {
if (bmArr[i] == oVal) {
itemFound = true;
}
else {
cStr += bmArr[i] + 'x';
}
}
}
if (!itemFound) {
cStr += oVal +'x';
setBookmarkCookie(cStr);
}
}
else {
cStr = oVal + 'x';
setBookmarkCookie(cStr);
}
if (!itemFound) {
var oDiv = document.getElementById('abl_list');
if (oDiv) {
var aTable = oDiv.getElementsByTagName('table');
var oTable = aTable[0];
var oTBODY = oTable.tBodies.item(0);
var oTDtxt = document.createElement('td');
var oTxtA = document.createElement('a');
oTxtA.href = loc;
oTxtA.innerHTML = oTitle;
oTDtxt.appendChild(oTxtA);
var oTDdel = document.createElement('td');
oTDdel.className = 'delete';
var oDelA = document.createElement('a');
oDelA.href = '#';
oDelA.className = 'delete';
oDelA.onclick = function() {
return delBookmark(oVal);
}
oDelA.innerHTML = '<span>x</span>';
oTDdel.appendChild(oDelA);
var row = document.createElement('tr');
row.id = 'bm_' + oVal;
alert("hej");
row.appendChild(oTDtxt);
row.appendChild(oTDdel);
oTBODY.appendChild(row);
}
}
}
return false;
}
function setBookmarkCookie(val) {
var cv = readCookie(bookmarkCookieId);
if (cv) {
eraseCookie(bookmarkCookieId);
}
if (val != null) {
createCookie(bookmarkCookieId, val, 365);
}
}
function readBookmarkCookie() {
var cv = readCookie(bookmarkCookieId);
var res = null;
if (cv) {
res = cv.split('x');
}
return res;
}
/**** BOOKMARK FUNCTIONS ****/
/****************************/
------------------------------------------
HTML:
<!-- HIDE -->
<div id="inet_abl" style="display: none;">
<div id="abl_header">
Mine Genveje
</div>
<div id="abl_main">
<div id="abl_list">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr class="void">
<td></td><td class="delete"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- END HIDE -->
<a href="#" title="Til top">Til top</a> - <a href="java script: void(0);" onclick="javascipt:fncToggleShow('mailfriend');">Tip en ven</a> - <a href="#" onclick="return addBookmark();" title="Tilføj genvej">Tilføj genvej</a>