只从<iframe>鼠标悬停时

Only load link from <iframe> when mouse is hovering over

本文关键字:悬停 鼠标 iframe 只从      更新时间:2023-09-26

我在index.html中添加了一个模板,使用了以下代码。问题是我有成千上万的<td>被附加在一个循环中。我有一种感觉,当我把这些都加进去的时候,它会在把鼠标悬停在链接上之前,为所有的<td>加载http://en.wikipedia.org。这显然不是一个可用的解决方案,因为它需要几个小时,如果不是几天,加载页面。我尝试的时候不得不关闭了网站。是否有一种方法来设置<iframe>,所以它只加载页面时,悬停在它?

template += " <td>";
template += "<a target='_blank' href="+entry['insta_url']+" style='display:block;'>";
template += entry['id'];
template += "</a>";
template += "<div class='box'><iframe src='http://en.wikipedia.org/' width = '500px' height = '500px'></iframe></div>";
template += "</td>";

您可以省略<iframe>src属性,然后通过JavaScript捕获mouseover事件,并在事件触发时设置src