如何让 chrome 重新渲染 iframe

时间:2020-12-31 13:47:55

标签: javascript html google-chrome iframe

谁能建议任何特定于 Chrome 的代码来强制它重新呈现 iframe?我们看到这种非常奇怪的现象,间歇性地,我们在页面上加载的 iframe 将全是白色的。当您移动鼠标时,您甚至可以看到底层元素的标题标签。只要您尝试在调试器中检查它,它就会立即自行修复。当您调整页面/iframe 大小时,它也会自行修复。我们无法想出一种方法来以编程方式检测何时发生这种情况,尽管 b/c 似乎是 Chrome 未呈现它的奇怪错误。是否有特定于 chrome 的代码告诉它进行重新渲染周期? (一个简单的 jquery 显示/隐藏不会影响它)在此先感谢您的任何建议!

you can still see the title tags on hover and access the dom elements via javascript

2 个答案:

答案 0 :(得分:1)

在 Chrome 中,重新加载 iframe 的代码是(使用纯 JavaScript):

  1. use Illuminate\Database\Eloquent\Relations\BelongsTo; $test = DmLog::withTrashed() ->with([ 'followup' => function (BelongsTo $relationship) { $relationship->select(['id', 'priority']); }, ]);
  2. document.getElementById('iframeID').location.reload();

第一种方法通过调用 document.getElementById('iframeid').src += ''; 方法重新加载 iframe,第二种方法通过附加一个空字符串重新加载 iframe,这会强制重新加载 iframe。

答案 1 :(得分:0)

您或许可以强制 iframe 的 CSS 重绘。一个技巧是读取高度

document.getElementById("yourIframe").contentDocument.documentElement.offsetHeight