Usage.txt example does not work
Donovan - March 4, 2009 - 02:25
| Project: | Prepopulate |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | minor |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Prepopulate is not working correctly on Drupal 6.10. For example:
The usage.txt file provides the following example bookmarklet:
javascript:u=document.location.href;t=document.title;s=window.getSelection();void(window.open(%22http://oif.eafarris.com/node/add/content-web-link?edit[title]=%22+escape(t)+'&edit[body_filter][body]='+escape(s)+'&edit[field_url][0][value]='+escape(u),'_blank','width=1024,height=500,status=yes,resizable=yes,scrollbars=yes'));I have modified it slightly to accommodate my site needs as follows:
<a href="javascript:u=document.location.href;t=document.title;s=window.getSelection();void(window.open(%22http://example.com/node/add/post?edit[title]=%22+escape(t)+'&edit[body_field][body]='+escape(s)+'&edit[field_link][0][url]='+escape(u),'_blank','width=1024,height=500,status=yes,resizable=yes,scrollbars=yes'));">postIT!</a>However, the bookmarklet fails as follows:
1. The form does not open in a new window
2. The fields are not populated with the correct values -- just the Javascript code as follows:
Link:
' escape(u),'_blank','width=1024,height=500,status=yes,resizable=yes,scrollbars=yes'));Title:
" escape(t) 'Body:
' escape(s) '
I have tried a number of variations of quotes and escape codes, but cannot get it to work. Please help. Thanks.

#1
This javascript is for a bookmarklet link in your browser window, rather than a link in your page. You've placed it inside an anchor 'a' tag, and this generates the error you're seeing.
Add a bookmark on your browser bar, and change the location from a URL to the javascript code. In Firefox, I have to right click (to get context menu) on a bookmark in my bookmark bar and click 'Properties', and change the location. In Safari I right click and select 'Edit Address'. Where the URL should normally go, paste in your edited code:
javascript:u=document.location.href;t=document.title;s=window.getSelection();void(window.open(%22http://oif.eafarris.com/node/add/content-web-link?edit[title]=%22+escape(t)+'&edit[body_filter][body]='+escape(s)+'&edit[field_url][0][value]='+escape(u),'_blank','width=1024,height=500,status=yes,resizable=yes,scrollbars=yes'));