动态 DOM 节点的快照小部件

发布于 2024-09-10 14:28:45 字数 378 浏览 6 评论 0原文

我正在使用 Snap.com 服务在我的网页上创建维基百科链接的快照。加载页面时,它可以与页面中的链接配合良好。但当新链接通过 Javascript 创建并插入到网页中时,它不起作用。

加载页面时会调用 Snap.com 脚本一次:

<html>
<body>
   ...
   <script type="text/javascript" src="http://shots.snap.com/ss/my-id/snap_shots.js"></script>
</body>
</html>

在文档中创建新的 DOM 节点后是否有办法重新激活其脚本?或者有其他方法来解决这个问题?

I'm using Snap.com service to create snapshots to Wikipedia links on my web page. It works fine with the links in the page when page is loaded. But it doesn't work when new links are created and inserted into the web page via Javascript.

The Snap.com script is called once when the page is loaded:

<html>
<body>
   ...
   <script type="text/javascript" src="http://shots.snap.com/ss/my-id/snap_shots.js"></script>
</body>
</html>

Is there a way to reacivate their script after new DOM nodes are created in the document? Or some other way to solve this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七分※倦醒 2024-09-17 14:28:45

我通过检查 Snap.com 来源找到了解决方案。
以下代码强制 Snap.com 重新处理页面:

SNAP_COM.shot_main_js_called = false;
SNAP_COM.shot_main_js();

I've found the solution by inspecting Snap.com sources.
The following code forces Snap.com to reprocess the page:

SNAP_COM.shot_main_js_called = false;
SNAP_COM.shot_main_js();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文