www.webdeveloper.com
Results 1 to 2 of 2

Thread: wordpress 'Press This' bookmarklet javascript issue

  1. #1
    Join Date
    Aug 2006
    Posts
    301

    Exclamation wordpress 'Press This' bookmarklet javascript issue

    hi guys i'd be most grateful if somebody can solve this issue:

    There is a 'technical note' on this page explaining this silly little problem and also tells how to update the bookmarklet but i can't get it to work:

    http://codex.wordpress.org/Press_This

    This is a video showing how to manual work around the problem each time you need to use the bookmarlet...

    https://www.youtube.com/watch?v=0PgfPp9NxxM

    This is the actual bookmarklet code:
    Code:
    javascript:var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='http://meta-blogger.com/wp-admin/press-this.php',l=d.location,e=encodeURIComponent,u=f+'?u='+e(l.href)+'&t='+e(d.title)+'&s='+e(s)+'&v=4';a=function(){if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570'))l.href=u;};if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();void(0)
    and this is an example of the url that the bookmarklet takes me to when i click on it, the part highlighted in blue is causing the problem, can you fix the bookmarklet code above so that it chops off the part in blue, once the part in blue is removed the bookmarklet works fine - i *really* tid to fix it myself but already spent more than 30 minutes to no avail:

    http://meta-blogger.com/wp-admin/press-this.php?u=http%3A%2F%2Fwww.quicksprout.com%2F2013%2F01%2F14%2F11-obvious-ab-tests-you-should-try%2F&t=11%20Obvious%20A%2FB%20Tests%20You%20Should%20Try&s=&v=4

    Thank you so much for your help, i recon that the replace() function should be able to chop that off but i'm not good with regexp.

  2. #2
    Join Date
    Aug 2006
    Posts
    301
    hi guys, couldn't give up so easily, so i decided to just use site=l.href.split("//") to split the url at // and the reference site[1] to get at the part of the url after the http://, and this works just fine, though prob not as elegant. cheers. hopes this help others - you'll need to right click onthe bookmarklet and choose edit and then paste the code below in overwriting the original code...

    Code:
    javascript:var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,site=l.href.split("//"),s=(e?e():(k)?k():(x?x.createRange().text:0)),f='http://meta-blogger.com/wp-admin/press-this.php',l=d.location,e=encodeURIComponent,u=f+'?u='+e(site[1])+'&t='+e(d.title)+'&s='+e(s)+'&v=4';a=function(){if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570'))l.href=u;};if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();void(0)
    Last edited by bsmbahamas; 04-02-2014 at 12:37 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles