单击IE/Edge上的LinkedIn共享按钮时出错 [英] Error on clicking the LinkedIn Share Button on IE/Edge

查看:47
本文介绍了单击IE/Edge上的LinkedIn共享按钮时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ReactJS应用中使用了LinkedIn的以下Share插件:

 < 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> 

来自LinkedIn文档:

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].

解决方案

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:

  1. Open Internet Explorer.
  2. Click Tools and select Compatibility View Settings.
  3. Uncheck the box next to "Display all websites in compatibility view".
  4. 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

这篇关于单击IE/Edge上的LinkedIn共享按钮时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆