Post bookmarklet suggestion

0 views
Skip to first unread message

David Hochman

unread,
Apr 23, 2008, 2:23:46 AM4/23/08
to Gnizr User Discussion
Dittos.

The "post" bookmarklet does not work in some cases in our enterprise.
The following version does work as expected in IE6.

javascript:(function(){setTimeout(function(){var g='<host>/gnizr/
post?', p='url='+encodeURIComponent(location.href)
+'&title='+encodeURIComponent(document.title); try{window.open(g+p
+'&saveAndClose=true','gnizr','toolbar=no,status=no,resizable=yes,width=800,height=640,scrollbars=yes');}
catch(e){location.href=g+p+'&saveAndClose=false&redirect=true';}},
10);})()

Here is some of the rationale:
The 2nd argument of window.open() was 'gnizr%202.4' and IE complained
-- I think it must be a valid target value, so no space or period
would be allowed. If the browser disables popup windows,
window.open() throws an error, and this catches that error, rather
than expecting it to return null. If Firefox needs setTimeout(), it
won't hurt other browsers. The whole thing is wrapped in an anonymous
function, so the JavaScript is "namespace" safe and won't overwrite
any page-specific variables. Expanded some of the shortcuts
(e=encodeURIComponent, d=document, l=d.location) for readability and
made the internal function anonymous, and the result is still shorter
than the original.

I can't promise it will work for every browser, but I hope you can
incorporate this suggestion to help improve the product.

Separately, the instructions to drag the links to the bookmarklets
folder don't work for IE, which requires you to right-click on each
link, choose Add to Favorites..., and save it in the Links subfolder.
And some people may need to be told how to enable the Links toolbar in
IE. It's just one of those things.

Harry Chen

unread,
Apr 23, 2008, 9:47:55 AM4/23/08
to gnizr...@googlegroups.com
David,

Thank you for the message.

> The "post" bookmarklet does not work in some cases in our enterprise.

> The following version does work as expected in IE6...

I will test you code and will try to roll it into 2.4.0-M3.

> Separately, the instructions to drag the links to the bookmarklets
> folder don't work for IE, which requires you to right-click on each
> link, choose Add to Favorites..., and save it in the Links subfolder.
> And some people may need to be told how to enable the Links toolbar in
> IE. It's just one of those things.

Good catch. I will include additional instructions on the page to
address this problem.

Thanks,

--
Harry Chen, Ph.D.
http://harry.hchen1.com
http://geospatialsemanticweb.com

> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups "Gnizr User Discussion" group.
> To post to this group, send email to gnizr...@googlegroups.com
> To unsubscribe from this group, send email to gnizr-users...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/gnizr-users?hl=en
> -~----------~----~----~----~------~----~------~--~---
>
>

Harry Chen

unread,
Apr 25, 2008, 1:55:27 PM4/25/08
to david....@gmail.com, gnizr...@googlegroups.com
David,

I tried your bookmarklet. It seems to function better than ours when
it's used in IE. I would like to use yours since it's shorter. But,
there is one problem...

The "catch" block of the new bookmarklet doesn't work in Apple Safari. I
tested on my Safari 3.1.1 (windows). The bookmarklet works fine if I
allow pop-up. But if pop-up is disabled, no error or warning message is
displayed.

I tried to injecting an "alert()" into the catch block, but that doesn't
seen to be executed.

Probably I need to do more investigation. If you have any thoughts on
the issue, please let me know.

Thanks,

- Harry

> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups "Gnizr User Discussion" group.
> To post to this group, send email to gnizr...@googlegroups.com
> To unsubscribe from this group, send email to gnizr-users...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/gnizr-users?hl=en
> -~----------~----~----~----~------~----~------~--~---
>
>

--

David Hochman

unread,
Apr 25, 2008, 5:39:53 PM4/25/08
to Gnizr User Discussion
Harry,

It always pays to test! I was overzealous in stating that
window.open() always throws an error (it can return null), and there
was a Safari workaround posted at http://aarongough.com/content/view/29/1/.
The following version handles those conditions. Also, I abbreviated
as much as possible to keep it under IE's 500-ish character limit on
bookmarklets. It continues to work in IE and FF, but I still can't
vouch for Safari.

javascript:(function(){setTimeout(function(){var g='<host>/gnizr/post?
url='+encodeURIComponent(location.href)
+'&title='+encodeURIComponent(document.title)+'&saveAndClose=';
try{var u=g+'true', t='gnizr',
o='toolbar=no,status=no,resizable=yes,width=800,height=640,scrollbars=yes',
w=window.open(u,t,o); if(!w)
{w=window.open('',t,o);w.location.href=u;}} catch(e){w=null;};
if(w==null){location.href=g+'false&redirect=true';}},10);})()

Thank you,
- David
Reply all
Reply to author
Forward
0 new messages