On page 1, I have a div
containing information.
<div id='information'></div>
And on page 2, I have a form
with a textarea
and a button.
<form>
<textarea id='new-info'></textarea>
<input type='submit' id='submit-info' value='pass'/>
</form>
Now what I want is when I click the submit button, the text inputted in the text area will be posted in div#information
changing its previous content.
I have seen many other post on how to change div content, but those were unrelated to my problem.
One way is to do like what the other answers mentioned, to have each tab communicate to a central server that will get/send data to keep both tabs updated using AJAX for example.
But I'm here to tell you about another way though, it's to use what we already have designed for this kind of task exactly. What so called browser
localStorage
Browser storage works like this pseudo code:
Where all the data will be shared among all open tabs for the same domain. And you can add event listener so whenever one value change, it will be reflected on all tabs.
Check out this DEMO, you edit one field on page-A, and that value will be reflected on page-B offline without the need to burden the network.
To learn more, read this.
Real live example. The background color is controlled from another tab.
Hope this will give you an idea of how you can do it:
Page 2
HTML
JS
save_data.php
Page 1
HTML
JS
This is exactly as the following: Page 1:
Page 2
You mean some thing like this ?
If you thing about server side, tell more about technology, which you use.