单击任何链接时,LinkedIn嵌入式帖子会自行删除

时间:2019-01-25 14:35:29

标签: iframe linkedin

使用 'Embed this post' 时,如果用户单击iFrame中任意位置的链接,则会破坏其中的html。您可以按照以下步骤复制此问题。

  1. 点击帖子右上角的“ ...”。
  2. 转到“嵌入此帖子”并复制iFrame代码。
  3. 将iFrame代码粘贴到可以测试HTML的位置。
  4. 单击嵌入式帖子中任意位置的链接。

这时您会看到该帖子消失了。头部和身体的HTML代码被破坏了。

我重复了问题here

<iframe src="https://www.linkedin.com/embed/feed/update/urn:li:share:6481527492011139072" height="777" width="504" frameborder="0" allowfullscreen=""></iframe>

尝试单击左上方的LinkedIn图标或点赞/评论/共享按钮。

我尝试在他们的网站上寻求LinkedIn支持,但是他们的团队将我引导到了这里。

1 个答案:

答案 0 :(得分:2)

Refused to display 'https://www.linkedin.com/authwall?trk=gf&trkInfo=AQFSSEZsXsstdAAAAWi4pJ9YQaz5O2_6IRmktVz1kDhxt_uchm59um--vI7OCCG1Nkz-xFDMqtML8ee4C6Min8NUMPsH3DihIAb3hbhB1WUdxyaT2NxjuAgsaAq6GPKgXJra2gA=&originalReferer=https://www.linkedin.com/embed/feed/update/urn:li:share:6481527492011139072&sessionRedirect=https%3A%2F%2Fwww.linkedin.com%2Fcompany%2Faps-technology%3Ftrk%3Dpublic-post_share-update_actor-text' in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self'"

由于设置了内容安全策略,因此禁止在IFRAME中显示内容。托管linkedin.com的网络服务器配置为将HTTP标头添加到响应对象。具体来说,他们正在将Content-Security-Policy标签设置为框架祖先的“自我”。您无法使用IFRAME将他们的页面嵌入到自己的页面中。您可以使用其他方法来解决此问题,但是没有任何一种技术比iframe代码更简单。

W3C Content Security Policy Level 3 - Frame Ancestors

所以,不是不是什么问题,而是Linkedin不允许您这样做。另外,如果您查看将要打开的网址,您会发现它们位于linkedin auth墙的后面