Home > Article > Web Front-end > js can realize the method of monitoring the F5 page to refresh the child iframe without refreshing the parent page.
The key point is to prevent the default refresh, so that the external page will not be refreshed, and then specify the refresh iframe. I have given the idea below
document.onkeypress = function(e){ if(e.keyCode == 116){ e.preventDefault(); //组织默认刷新 var iframeSrc = iframe.src; iframe.src = iframeSrc; } }
Write the following in the iframe page:
var iframeSrc = parent.iframe.src; document.onkeypress = function(e){ e.preventDefault(); parent.frame.src = iframeSrc; }