Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是一个巨大的远景,但无论如何我都会尝试 :-) 假设在 Chrome 扩展程序中我有两个页面(比如,选项页面和弹出页面)并且我想在它们之间移动一个 DOM 对象(比如,一个 iframe播放 YouTube 电影)。有没有办法做到这一点?
您可以通过以下方式获得内部 htlm
saved_html = dom_node.innerHTML
将 dom 节点作为字符串,您可以将其保存在 localStorage 或 cookie 中(不确定哪个在 chrome 扩展中有效)。在另一页,将其加载到容器中:
container.innerHTML = saved_html
注意:状态不会被保存,所以如果你播放视频,它仍然会在其他网站上暂停。如果 iframe 不在您的域中,您也无法访问它的 innerHTML。