Hi,

I'm trying to get a jscript working so I can bookmark pages using weblink. Here's what I've tried, javacript:location.href='http://www.test.com/node/add/weblink?edit&url='+encodeURIComponent
(location.href)+'&title='+encodeURIComponent(document.title) but it fails.

Any ideas? I want to be able to grab the tilte and url.

Thanks,

Jim

CommentFileSizeAuthor
#2 weblink-query.patch.txt1.39 KBEgon Bianchet

Comments

syscrusher’s picture

I'm not sure the forms library in Drupal will accept GET (rather than POST) parameters, but assuming it does, you need to check your variable names. The "edit" parameter is an array containing the others, so you need something like ..../weblink?edit['url']=http://www.example.com&edit['title']=This+is+my+title instead of having "edit" as a separate value-less parameter. You'll need to URLencode variable names like "edit['url']" of course. I don't have an ASCII chart handy to do that here.

Please let me know what you find when you try this. You may need to submit with a POST rather than a GET request.

Scott

Egon Bianchet’s picture

Title: jscript question » Get title, url and description from the query string
Status: Active » Needs review
StatusFileSize
new1.39 KB

This patch makes it work with a query string like this:

&title=title&url=url&description=description

The description parameter is put into the body.

Many bookmarklets use this format, and above all it would work with my nodeformpopup module ;-)

Egon Bianchet’s picture

Forget the patch, I'm going to use a form_alter in my module

Egon Bianchet’s picture

Status: Needs review » Active