[Development skills] · html page and automatically refresh implementation returns

Copyright Notice: Copyright - Xiao Song is it - yansongsong.cn - welcome to reprint https://blog.csdn.net/xiaosongshine/article/details/85065581

[Development skills] · html page and automatically refresh implementation returns

Website -> http://www.yansongsong.cn

  • Problem Description

During the development of APP or for the production site, sometimes encounter the results will change on a page after a page operated under you. This time we need to go to the previous page refresh.
Generally taken in three ways:

  1. Regularly updated
  2. With eventListener, detection event
  3. Use execScript, execute external js

I chose a third way, simple operation, high efficiency, and less code.

  • Routine (based Apicloud platform)

We win: a.html opened a frame: a_frame.html, then jumps to win: b.html opened a frame: b_frame.html.
Now we need to return to win: a.html, update frame: a_frame.html the contents inside.

Operation, adding b_frame.html JavaScript code:

function winReload(winName, frameName) {
        var jsFun = 'location.reload();';
        api.execScript({
            name: winName,
            frameName: frameName,
            script: jsFun
        });
    }

Execution, when b_frame.html calculate the results, need to return a.html, call:

winReload("a", "a_frame");

Because my data is on the server side, when executed location.reload()automatically obtain updates from the server side, if your data is stored locally, you can use parameter passing, or setStorge () method.

Guess you like

Origin blog.csdn.net/xiaosongshine/article/details/85065581