-
Message between browsers
Sending messages between two browser instances. The receiver needs to add a custom message handler. The other need the message sending method.
"visualwindows" : [ { "name" : "nav", "type" : "browser", "url" : "nav.html", "rect" : [0,40,250,-40] }, { "name" : "main", "type" : "browser", "url" : "rightasync.html", "rect" : [250,40,-1,-40] } ], <br>
The definition for the two browser windows.
<script src="https://global.assets/js/2imply.js"></script>
To do this you need to load 2imply.js in both instances.
app.setcustomhandler(function(event) { let jdata = {}; try { jdata = JSON.parse(event.data); } catch { jdata = {'cmd' : 'unknown', 'msg' : event.data, 'requestid' : 0}; } $("#message").html(jdata.title); }); <br>
Receiving instance have a div with id="message" where we set the data. Name of the browser object when defined is "main"
<button class="btn btn-warning" onclick="app.sendmessageto('main',{title : 'hello there'});">Send message</button>
Sending instance just loads 2imply.js and use the method with app to send to the "main" browser object.