我有此javascript代码用于邮寄,在网络上可以正常工作:
<script>
var popup;
window.addEventListener('message', function(e) {
console.log(e.origin);
if (popup != null) {
var reply = JSON.stringify( {'msg' : 'Message' } );
popup.postMessage(reply, e.origin);
}
});
function openRemotePage() {
popup = window.open('website.com' );
}
</script>
我希望在Ionic打字稿中具有类似的功能。
答案 0 :(得分:0)
public static popup:any;
public openRemotePage():void{
window.addEventListener('message', function(e) {
var msg = JSON.parse(e.data);
if (MyModal.popup!= null) {
var reply = JSON.stringify( {'msg' : 'Message' } );
MyModal.popup.postMessage(reply, e.origin);
}
});
MyModal.popup = window.open('website.com');
}