javascript - Change element attribute of another page -
hello guys have problem website. here's situation:
page 1
<script type="text/javascript" src="jscript.js"> <input type="button" value="change" onclick="changeattr()"> page 2
<script type="text/javascript" src="jscript.js"> <input type="text" value="hello" id="dynamictext"> jscript.js
function changeattr(){ document.getelemenybyid('dynamictext').value="world"; } now these 2 pages open on different tabs. want happen whenever button on page 1 clicked, value of input text on page 2 change "world". how can make possible javascript or jquery?
the 1st tab has task change value in localstorage. localstorage.setitem('supervalue', 'world');
meanwhile 2nd tab "listen" changes on localstorage value:
var dinamictext = document.queryselector('dinamictext'); setinterval(function () { if (dinamictext.value !== localstorage['supervalue']) { dinamictext.value = localstorage['supervalue']; } }, 100); this of course works pages on same domain.
Comments
Post a Comment