javascript - Changing CSS proprety of another div located in another page -


hello change dom of html page page tried sharing same script between 2 pages didnt work here illustration trying do

1-first page

<div> <p id="simpletext">hello world</p> <script src="jquery.min.js"></script> <script src="script.js" type ="text/javascript"></script> <!-- same script file present in second page --> </div> 

2-second page

<div> <button>click me </button> <script src="jquery.min.js"></script> <script src="script.js" type ="text/javascript"></script><!-- same script file present in first page --> </div> 

script.js

 $("button").on("click",function(){     $("simpletext").css("color","blue");     }); 

i trying when click on button wish located on second page change color of text on first page

you can send messages 1 page another. @ buttons side send message:

 $("button").on("click",function(){    wondow.postmessage("show","*"); }); 

then @ other page, wait message:

 window.addeventlistener("message",function(event){    if(event.data === "show") {      $("simpletext").css("color","blue");    } }); 

i assume both windows opened on same machine, if not, need ajax or websockets instead , serverside proxying.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -