user3763227 user3763227 - 1 month ago 11
Ajax Question

Refresh a page(1st page) from another page (3rd page) using javascript

To reload/refresh a page from another page using JavaScript. (A page, which is already opened in the browser. I need to refresh it (not open again) from another page.)

I refer a lot, but i can't get the exact answer i want.

How to refresh another page using javascript without opening the same page in a new tab

I referred this page. But it has a parent and child page. But i need to refresh a unrelated page from another page.
Is this possible?

If so, give me some suggestion.

Explanation of my actual project:

There is a pageA from that using Ajax i called some other page(inside a div of pageA). Then by clicking a link in that div (present in page called from Ajax), it will open a pageB in new tab in the same browser. in that page, when user clicks a button, It will call another page, in that page i do a table update. After that update, pageA should be refreshed. This is the actual project what i have to do.


Assuming this is in the same browser and the same domain a simple way is as follows (pseudo code)

Page A -> controller
Page B -> page to be refreshed.

The steps are:-

Page A Calls a Javascript function (via button press for example) that writes a value of 'update: true' to local storage.

Page B has a loop of 500ms that checks this value in local storage - when it sees 'update: true' it sets it back to false and then refreshes itself.

These are all simple things to look-up how to do but if you get stuck just let me know.

Oh and same principle applies on different browsers (i.e. if Page A opened in chrome, Page B opened in Firefox) - just that instead of local storage you use a server and store the state to DB / a file.

Below is a quick example - open the two pages in different tabs then click 'refresh' in the controller apge - you will notice the 'page to be refreshed' page refreshes.