Twitter share button not working in IE and FF when within modal


#1

Hello,

Apologies if this has been raised before but couldn’t see anything recent on the forum.

I came across a bit of an odd bug recently, using https://dev.twitter.com/web/tweet-button within a pop-up modal was working as expected in Chrome, but in Firefox, Edge and Internet Explorer the tweet button wouldn’t appear.

After a lot of investigation, it appears to be down to the fact the content within the modal is hidden using display none.

Eventually I worked around this using the following:

$(shareModalBtn).on( "click", function() { 
		shareModal.show();
		//share modal FF/IE twitter fix
		var twitterBtn = $('#twitter-widget-0');
		if (twitterBtn.width() < 2) {
				var shareHtml = "";
				var el = $('#twitterShareIEFF');
				var shareUrl = window.location.href;
				var shareTwitterLabel = el.data("twitter-label");
				var shareTwitterText = el.data("twitter-text");

				if (shareTwitterLabel != undefined) {
					shareHtml += '<a href="https://twitter.com/intent/tweet?text='+shareTwitterText+'&url='+shareUrl+'" title="'+shareTwitterLabel+'" target="_blank"><img src="/assets_src/images/tweetbtn.png" alt="Twitter"></a>';
					el.text('').append(shareHtml);
				}
		}
});

So, checking if the twitter-widget-0 was less than 2px wide (which is what was happening in non Chrome browsers)
Then manually create and insert the twitter button.

This may well be an edge case but wanted to share in case anyone came across something similar, or if this is fixed in the future.


Twttr.widgets.load() doesn't render hidden elements properly
Tweet button is invisible in Edge (when in AngularUI modal)
#2

Hi there,

Do you have a link to reproduce this issue?


#3

Hi @lananelson I fixed it on the live site but have recreated it here:
https://codepen.io/jowoos/pen/aqLPLg

Hopefully you’ll see when “share this article” is clicked in Chrome the Tweet button appears but in Firefox the Tweet button does not appear.

Hope that helps


#4

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.