问题
I am using the below Share Plugin of LinkedIn in my ReactJS app:
<script src="https://platform.linkedin.com/in.js" type="text/javascript">lang: en_US</script>
<script type="IN/Share" data-url="https://www.linkedin.com"></script>
From LinkedIn Docs: https://docs.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/plugins/share-plugin
It is working completely fine on Chrome/Firefox/Safari. But, on clicking the LinkedIn Share button (generated by the above scripts), the LinkedIn Share Popup appears and I get an error in my app console which says:
[object Error]: {description: "[Messenger] Required property 'target' was not provided", message: "[Messenger] Required property 'target' was not provided", nr@seenError: true, stack: "Error: [Messenger] Required property 'target' was not provided at Anonymous function (https://platform.linkedin.com/xdoor/scripts/in.js:7:55143) at Array.prototype.forEach (native code) at t (https://platform.linkedin.com/xdoor/scripts/in.js:7:54936) at e (https://platform.linkedin.com/xdoor/scripts/in.js:7:56462) at e (https://platform.linkedin.com/xdoor/scripts/in.js:7:34661) at value (https://platform.linkedin.com/xdoor/scripts/in.js:18:23834) at s (https://platform.linkedin.com/xdoor/scripts/in.js:18:38221) at nrWrapper ([MY_SITE_LINK_ADDRESS]:9:16587)"}
Note: I hid the [MY_SITE_LINK_ADDRESS].
回答1:
The problem here seems to be that you're relying on the plugin's JS, CSS, and HTML to handle every browser. Take a look: Here's someone else posting in 2018 having the same exact problem, Issue on IE with LinkedIn Share plugin. And, officially from LinkedIn, if you want this plugin to work, you need to ask your users to do this:
- Open Internet Explorer.
- Click Tools and select Compatibility View Settings.
- Uncheck the box next to "Display all websites in compatibility view".
- Click Close.
Is it reasonable to ask your users to reconfigure their browser just to be able to click one, single button on your website? Answer: No.
You don't need to rely on the LinkedIn Share Plugin. All you really ought to need is...
https://www.linkedin.com/sharing/share-offsite/?url={url}
Then making sure it works cross-browser is in your hands.
Source: Microsoft LinkedIn Share URL Documentation.
Sure, everyone says: Don't Reinvent the Wheel! I totally agree! But when you find a car that has square, cubic wheels, then maybe you want to reconsider!
If you are interested in a regularly maintained GitHub project that keeps track of this so you don't have to, check it out! Social Share URLs
来源:https://stackoverflow.com/questions/55220126/error-on-clicking-the-linkedin-share-button-on-ie-edge