function RWEncodeItReplace ($0,$1) { //contverts $1 to entity return '&#'+$1.charCodeAt (0)+';'; } function RWEncodeIt (s) { //encodes or chars over 127 return s.replace (/([^ -~])/g,RWEncodeItReplace) } function getFrames() { var sFrames = ''; try { var f = document.frames; //alert(f.length); for (i=0; i < f.length; i++) { try { sFrames += f(i).document.body.parentNode.innerHTML; } catch(e) { //alert(i + ': ERROR - ' + e.message); } } } catch(e) { //alert('ERROR - ' + e.message); } //alert('Total='+sFrames.length); e = document.getElementById("RWFrames"); e.value = RWEncodeIt(sFrames); } function RWAddToRW1() { var sId ="AddToRWForm"; if (!document.getElementById(sId)) { var sPage = document.body.parentNode.innerHTML; var f = document.createElement("form"); f.action = "http://www.refworks.com/rwbookmark/bookmarklanding.asp"; f.target = "RefWorksBookmark"; f.method = "POST"; f.id = sId; document.body.appendChild(f); e = document.createElement("input"); e.type = "hidden"; e.name = "RWURL"; e.value = window.location.href; f.appendChild(e); e = document.createElement("input"); e.type = "hidden"; e.name = "RWTitle"; e.value = RWEncodeIt(document.title); f.appendChild(e); e = document.createElement("input"); e.type = "hidden"; e.name = "RWSel"; e.id = "RWSel"; f.appendChild(e); e = document.createElement("input"); e.type = "hidden"; e.name = "RWFrames"; e.id = "RWFrames"; f.appendChild(e); e = document.createElement("input"); e.type = "hidden"; e.name = "RWPage"; e.value = RWEncodeIt(sPage); f.appendChild(e); } getFrames(); try {// catch error if no selection e = document.getElementById("RWSel"); if (document.getSelection) e.value = RWEncodeIt(document.getSelection()); else if (s=document.selection) e.value = RWEncodeIt(s.createRange().text); else e.value = RWEncodeIt(window.getSelection()); } catch (e) { } document.getElementById(sId).submit(); wRWMain1.focus(); } RWAddToRW1();