Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
222 views
in Technique[技术] by (71.8m points)

javascript - how to make chrome re-render an iframe

Can anyone suggest any code specific to Chrome to force it to re-render an iframe? We are seeing this really strange phenomenon where intermittently, the iframe we load on the page will be all white. When you move your mouse, you can even see the title tags of the underlying elements. As soon as you try to inspect it in the debugger, it instantly fixes itself. It also fixes itself when you resize the page/iframe. We haven't been able to come up with a way to detect programmatically when this is happening though b/c it just seems to be a weird bug with Chrome not rendering it. Is there code specific to chrome to tell it to do a re-render cycle? (a simple jquery show/hide doesn't affect it) Thanks in advance for any suggestions!

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In chrome, the code for reloading an iframe is (using pure JavaScript):

  1. document.getElementById('iframeID').location.reload();
  2. document.getElementById('iframeid').src += '';

The first method reloads the iframe by calling that reload() method, the second method reloads the iframe by appending an empty string, which forces the iframe to reload.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...