· HTML implementation returns the page and automatically refreshes
Personal website – > www.yansongsong.cn
- Problem description
When developing an APP or making a website, you will sometimes encounter the result that the next level of the page will change after you have done something on it. At this point, we need to refresh the previous page. Generally, there are three ways:
- Time to refresh
- Use eventListener to detect events
- Using execScript, execute JS externally
I choose is the third way, simple operation, high efficiency, and less code.
- Routines (based on Apicloud platform)
We open a frame: a_frame.html in Win: a.html, and then jump to Win: b.html and open a frame: b_frame.html. Now we need to go back to win: a.html and update the contents of frame: a_frame.html.
Add the following action to the b_frame. HTML JavaScript code:
function winReload(winName, frameName) {
var jsFun = 'location.reload(); ';
api.execScript({
name: winName,
frameName: frameName,
script: jsFun
});
}
Copy the code
Execute, when b_frame. HTML calculates the result and needs to return A.html, call:
winReload("a"."a_frame");
Copy the code
Since my data is on the server side, when location.reload() is executed it automatically gets updates from the server side. If your data is stored locally, you can use parameter passing, or the setStorge() method.