A pop up window is opened from the TBA file in the sidebar.
An error is caused by trying to point to the json global variable in sidebar opener from the popup, which is where the origin gets confused I guess.
A pop up window is opened from the TBA file in the sidebar.
An error is caused by trying to point to the json global variable in sidebar opener from the popup, which is where the origin gets confused I guess.
As you can see from the screenshot I have been able to transfer a json object from the TBA interface in the sidebar to the popup window and vice versa. window.postMessage()
did the trick. Not as good as having nset (the hierarchy of named sets) in the parent of iframes but workable I think. Maybe the nset can be split into shared and responsibility packets for greater speed and flexibility.
Not just a picture; here is the code:
In popup
window.addEventListener("message", receiveMessage, false);
function start(){
$(document).ready(function(){
root = '1grsin';
trial = 'msm4r';
orig = 'ozs29';
code = orig;
path = "https://api.myjson.com/bins/"+code;
$.get(path)
.done((data, textStatus, jqXHR)=>{
nset = data;
opener.postMessage(nset,"https://n-rxnikgfd6bqtnglngjmbaz3j2p7cbcqce3dihry-0lu-script.googleusercontent.com");
})
})
}
function receiveMessage(event) {
console.log(event.data);
$("#notice").html("Origin: "+ event.origin)
}
In TBA in sidebar
window.addEventListener("message", receiveMessage, false);
var popup;
function openMonitor(nset){
var params = [
'height=400',
'width=400'
].join(',');
let file = 'http://glasier.hk/blazer/model/model.html';
popup = window.open(file,'popup_window', params);
popup.moveTo(100,100);
}
function receiveMessage(event) {
console.log("origin: " +event.origin);
console.log(event.data);
popup.postMessage(nset, "http://glasier.hk");
}