JavascriptIFrame force refresh code _ javascript skills

Source: Internet
Author: User
Multiple iframe is often used to display the main and sub-relationships (master and sub-Orders) of the domain model. The test shows that iframe has the cache function. When the first time you enter an iframe {A} from the main window, at this time, the data presented in {A} is new, and I clicked another iframe for short {B}. Here, the data in {B} is also new, perform some logic processing in {B}. For example, add model data in batches to {A}. Here we enter {A} And we will find that the data is cached. Because {A} data is operated in batches from {B}, {B} communicates with the server, that is, it performs logical/persistent layer operations, in this way, the server updates are presented in part {B} rather than all, that is, partial refreshing, only refreshing {B }. What we need to do is to change the content in {.

Solution:
· Obviously, iframe. window. location. reload (); does not meet the current requirements.
· Use window. setTimeout (iframe. window. loadction. reload (), 1000); this method will cause multiple refreshes. What if we want to update the data of {B} in {?
· After studying for a long time, you can solve the iframe cache problem directly. It is easy to simply prevent it from being cached. If you do not cache it, you do not need to refresh it.
Example:

The Code is as follows:


Function doInsert2BatchCallBack (){
Var pIf = parent.doc ument. getElementById ('iframe _ ');
PIf. src = pIf. src + "&". concat (Math. random ());
// Submit a batch import request
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.