Question

I have created a bookmarklet to do basically what I have been wanting.

javascript:location.href=
"https://www.facebook.com/sharer/sharer.php?u="
+ encodeURIComponent(document.URL);

However, there are some problems - some may not be possible to do.

1) When I click on the bookmarklet, it will open up the website from Facebook, but when I actually share the content, it will close the tab...not go back to the original website

2) I have to select that I want to share the content to a Facebook Group, and then find the group in the list. What I want to do is have that done automatically!

3) I sometimes have to remove unneeded parts from the URL. Like on Youtube, it might add the "&t=xx" parameter that I mostly don't want...but this might also be problematic for other websites, too.

I don't know if #2 is possible, but I assume #1 is, and I am pretty sure #3 can be done with OpenDialog with location parameter.

Also, it would be nice, but I am more than certain that we cannot back-date a post via the sharer.php webpage...but if there is a way to do that in that dialog box, then that would be cool!


So to wrap up, how do I modify my code to use a dialog box. I have tried window.openDialog, but I might have been doing it wrong...and if possible how to do any of the remaining.

Was it helpful?

Solution

OK...this is what I was looking for, after I went to Google+ for some help. https://plus.google.com/u/0/106985204948741157372/posts/hbMDfwHiQBD...

javascript:window.open("https://www.facebook.com/sharer/sharer.php?u=" + 
document.URL, "Share Content To Facebook", "location=yes");

...however, there is one big problem with it! I cannot modify the URL in the location bar!!

A slight workaround is available, but it is a little undesirable as most of the time the URL is what I want, and I have no need to modify it...

javascript:window.open("https://www.facebook.com/sharer/sharer.php?u=" + 
prompt("Please check the URL below is correct:", document.URL));.

OTHER TIPS

You can bookmark this code in the bookmark bar. I tested the code above but there are some problems with the window which is opened. Code:

javascript: !(function() {
  var title = document.title;
  window.open(
    "https://www.facebook.com/sharer/sharer.php?u=" +
      escape(window.location.href) +
      "&t=" +
      title,
    title,
    "menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600"
  );
})();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top