Create a facebook share dialog for both mobile and desktop

Recently I ran into some trouble with a FB.ui share dialog, it worked just fine with some browsers but not on chrome/safari and mobile devices.

The fix for making it work in Chrome and Safari was to add display: popup, yet still nothing would happen om mobile devices.

The solution was to use the following code, that checks if it’s a mobile device and instead redirects the user to and creates the share dialog there.

[wpgist id=”207a8779e9e6e2fc8de6″]

If you have any questions or problems with the code above, don’t hesitate to ask me.

av Olaf Lindström

WordPress Developer and part time hostel owner. Possibly spending too much time on Smalspåret narrow gauge railway.

2 kommentarer

  1. I have similar issue, I want my users to be able to share with specific people. The web UI share dialog has this ability, but mobile version doesn’t it is annoying. Will try above method though and let you know.

    1. Sharing with specific people shouldn’t be a problem with this method. I tested it out on latest iOS and latest Android and had that option. I hope it worked out for you as well? 🙂

Lämna en kommentar

Din e-postadress kommer inte publiceras.