【问题标题】:Soundcloud embedded player (iframe) without cookies没有 cookie 的 Soundcloud 嵌入式播放器 (iframe)
【发布时间】:2021-12-22 06:51:17
【问题描述】:

iframe 中使用嵌入式 Soundcloud 播放器时:

<iframe width="100%" height="300" scrolling="no" frameborder="no" allow="autoplay" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/251273255&color=%23ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true"></iframe>

它存储 cookie。

如何在没有 cookie 的情况下嵌入 Soundcloud 播放器?

注意:我已经按照Recommended method to prevent any content inside iframe from setting cookies 的建议尝试了<iframe ... sandbox> 甚至sandbox="allow-scripts",但是播放器无法正常工作。

【问题讨论】:

标签: html cookies iframe sandbox soundcloud


【解决方案1】:

这个问题类似于: Disable Cookies Inside A Frame/Iframe

但这是您需要的代码:

<iframe  sandbox="allow-scripts" src="//w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/251273255&color=%23ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true"></iframe>

此代码阻止 cookie 并允许缓存并且缓存不是 cookie。虽然相似,但它们并不相同。这证明它只需要缓存而不需要 cookie。

【讨论】:

  • 您链接的问题的答案是“使用沙盒模式”。我在我的问题中提到我已经尝试过沙盒模式,但没有成功。它不起作用。
  • 你能添加一些代码来展示你是如何让它工作的吗?谢谢。
  • 这回答了你的问题吗?
  • 它根本不起作用@VarunW。您能否提供一个显示您的技术的示例 html 页面的链接?使用 sandbox="allow-scripts" 时,播放器不会显示给我。
【解决方案2】:
<iframe sandbox="allow-same-origin allow-scripts allow-popups allow-forms" width="100%" height="300" scrolling="no" frameborder="no" allow="autoplay" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/251273255&color=%23ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true"></iframe>

请试试这个sandbox="allow-same-origin allow-scripts allow-popups allow-forms"

【讨论】:

  • 我试过这个,但是cookies被存储了(查看你的浏览器开发工具,然后“存储”标签>你会看到来自soundcloud.com的cookies)
猜你喜欢
  • 2015-09-07
  • 1970-01-01
  • 2020-05-03
  • 2017-01-30
  • 2013-09-19
  • 1970-01-01
  • 2015-07-31
  • 1970-01-01
  • 2022-12-28
相关资源
最近更新 更多