W3C

Some Javascript Hacks for Excerpting from the Web

The Bookmarklets for quoting

Drag and drop these to your toolbar in your browsers.

Explanations

If you like to excerpt from the web (cf editing in designissues) as much as I do, you might find this little snippet of javascript handy:

  w=window.open("");
  w=document.write("<textarea rows='20' cols='80'>\n"
    +"<blockquote cite='"+location.href+"'>\n"
    +"<p>"+document.getSelection()+"</p>\n"
    +"</blockquote>\n"
    +"<p><cite><a href='"+location.href+"'>"
    +document.title+"</a><br/>"
    +new Date(document.lastModified).toUTCString()
    +"</cite></p>\n"
    +"</textarea>")

Note: This version of the script has been created after the mail How to create a quote with a bookmarklet

and this one, for email:

location.href='mailto:?SUBJECT='+escape(document.title)
+'&BODY='+escape('[[[\n'
+document.getSelection()
+'\n]]]\n\n-- '
+document.title+'\n'
+location.href+'\n'
+new Date(document.lastModified).toUTCString())

(Connolly, Aug 2000): Try these bookmarklets, i.e. javascript hacks:

They're illegal URIs, cuz they have spaces in them. But NS4 doesn't seem to deal with %20 in javascript: URIs well. @@need to report a bug.

Discussion

My code was hacked for NS4 and doesn't work with IE. But just after I released it...

Your JavaScript hacks, re-hacked for IE --

------------------------

javascript:Hd=document.title; Qu=document.selection.createRange(); 
Today=new Date(document.lastModified).toUTCString();
void(window.open('').document.write('<blockquote>' +Qu.htmlText+ 
'<br><br><address><a 
href=\''+location.href+'\'>'+Hd+'</a><br><br>'+Today+ 
'</address></blockquote>')) 

javascript: msg=document.title+'%20-->%20'+location.href;
location.href='mailto:drdee@bigfoot.com?Subject=url-4-u&Body='+msg

--------------------------

The 'mailto' bookmarklet doesn't include the quoted content due to string 
length limitations (apparently) in IE. It also didn't work in MS's own(!) 
Internet Mail client (a bug that adds everything after '?' to the Subject 
field) however it works just fine for me with Eudora as the client.
--Derek Robinson
Tue, 29 Aug 2000 19:10:11 +0100

@@amaya has a bug with "'s in attribute values. need to report it.

References


Dan Connolly, Aug 2000
$Revision: 1.16 $ of $Date: 2006/09/27 06:33:28 $ by $Author: kdubost $