Home > Web Front-end > JS Tutorial > js can realize the method of monitoring the F5 page to refresh the child iframe without refreshing the parent page.

js can realize the method of monitoring the F5 page to refresh the child iframe without refreshing the parent page.

高洛峰
Release: 2016-12-07 13:37:08
Original
1919 people have browsed it

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;
  }
}
Copy after login

Write the following in the iframe page:

var iframeSrc = parent.iframe.src;
document.onkeypress = function(e){
  e.preventDefault();
  parent.frame.src = iframeSrc;
}
Copy after login


Related labels:
js
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template