[gutvol-p] Bookmark (bookmarklet)

bert bertius at sympatico.ca
Sun Jan 9 20:02:37 PST 2005


This is a bookmarklet version of the javascript tool. The main advantage 
is that you don't have to alter the HTML file in order to use a bookmark.

Once installed, use the bookmarlet to return to a bookmarked paragraph.

Since my script is a bit long it cannot be installed as a regular 
bookmarklet. So, to install:

1- create a new bookmark (this can be done by bookmarking any html page)
2- go to Bookmarks -> Manage bookmarks...
3- right-click on your new bookmark -> Properties
4- change the name (optional)
5- replace the location with the following:

javascript:(function(){function init(){var 
bookmark=getCookie('bookmark');if(bookmark==null){bookmark=0;}var 
p=document.getElementsByTagName('p');var 
b=document.getElementsByTagName('body');var 
mark=document.getElementById('mark');if(mark!=null){b[0].removeChild(mark);}mark=document.createElement('a');mark.name='bookmark';mark.id='mark';mark.innerHTML='<hr 
/>';b[0].insertBefore(mark,p[bookmark]);p[bookmark].style.backgroundColor='lavender';for(var 
i=0;i<p.length;i++){p[i].ondblclick=highlight;p[i].id=i;}document.location='#bookmark';}function 
highlight(e){var p=document.getElementsByTagName('p');for(var 
i=0;i<p.length;i++){p[i].style.backgroundColor='white';}var 
targ;if(!e)e=window.event;if(e.target)targ=e.target;else 
if(e.srcElement)targ=e.srcElement;if(targ.nodeType==3)targ=targ.parentNode;targ.style.backgroundColor='lavender';setCookie('bookmark',targ.id,365);}function 
getCookie(NameOfCookie){if(document.cookie.length>0){var 
begin=document.cookie.indexOf(NameOfCookie+'=');if(begin!=-1){begin+=NameOfCookie.length+1;var 
end=document.cookie.indexOf(';',begin);if(end==-1)end=document.cookie.length;return 
unescape(document.cookie.substring(begin,end));}}return null;}function 
setCookie(NameOfCookie,value,expiredays){var ExpireDate=new 
Date();ExpireDate.setTime(ExpireDate.getTime()+(expiredays*24*3600*1000));document.cookie=NameOfCookie+%22=%22+escape(value)+((expiredays==null)?'':'; 
expires='+ExpireDate.toGMTString());}init();})();



More information about the gutvol-p mailing list