Home >Web Front-end >JS Tutorial >javascript IFrame forced refresh code_javascript skills

javascript IFrame forced refresh code_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:49:321259browse

When entering an iframe abbreviation {A} from the main window for the first time, the data presented in {A} is new. At this time, I clicked another iframe abbreviation {B}, here {B} The data is also new. Some logical processing is performed in {B}, such as adding model data in batches to {A}. Here, when we enter {A} again, we will find that the data is cached. Because the data of {A} is operated in batches from {B}, {B} communicates with the server, that is, it performs logical layer/persistence layer operations, so that the rendering part updated on the server side is {B} instead of All, this is a partial refresh, only {B} is refreshed. What we need to do is make the content in {A} change accordingly.

Solution:
·Obviously iframe.window.location.reload(); does not meet current needs.
·Use window.setTimeout(iframe.window.loadction.reload(),1000); This method will cause multiple refreshes. What if you want to update the data of {B} in {A}?
·After researching for a long time, we can actually solve it directly from the iframe cache problem. It is very easy. If we just don’t let it cache, it will be over. If it is not cached, of course there will be no need to refresh.
Example:

Copy code The code is as follows:

function doInsert2BatchCallBack() {
var pIf = parent.document.getElementById('IFRAME_A');
pIf.src = pIf.src "&".concat(Math.random());
//Submit batch import request
}
Statement:
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