Facebook Share Dialog IE8
by Riley MacDonald, August 12, 2013

Using the Facebook Share Dialog provided by the Facebook Developer Page, I discovered it was not working in IE8. The error console provided an ‘invalid argument’ error. After some debugging I discovered it was the ‘name’ parameter of the window.open() call. IE8 fails to run the script if any dashes are used in the name parameter. Other browsers do not seem to have a problem with this.

The provided FB share code:

1
2
3
4
5
6
7
8
9
<a href="#" 
  onclick="
    window.open(
      'https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href), 
      'facebook-share-dialog', 
      'width=626,height=436'); 
    return false;">
  Share on Facebook
</a>

The name parameter ‘facebook-share-dialog’ must have the dashes removed:

1
2
3
4
5
6
7
8
9
<a href="#" 
  onclick="
    window.open(
      'https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href), 
      'facebook_share_dialog', 
      'width=626,height=436'); 
    return false;">
  Share on Facebook
</a>

Voila the share button now works in IE8.

Open the comment form

Leave a comment:

Comments will be reviewed before they are posted.

User Comments:

Emanuele on 2014-05-16 09:49:46 said:
Thanks for the help. I just spent 45 minutes for this...

anusha on 2013-12-06 10:22:08 said:
awesome.. i spent almost 2 hours for this... thank you so much:)

Chris S on 2013-11-14 14:36:05 said:
Thanks for the help. I just spent 30 minutes thinking about how to resolve this.

John S on 2013-10-05 01:51:12 said:
Thank you very much for this explanation. After two hours of search, I finally found the solution that worked perfectly.

How to Add Facebook Share Dialog On Your Page | Tim Yao on 2013-09-24 01:42:36 said:
[…] After search I found this solution is working for me:  https://rileymacdonald.ca/2013/08/12/facebook-share-dialog-ie8/ […]