//用于嵌入到jupyter pod中的js //guange 2019.12.18 window.onload=function(){ console.log("开始发送消息了"); runEvery10Sec(); } function runEvery10Sec() { // 1000 * 10 = 10 秒钟 console.log("每隔10秒中一次"); require(["base/js/namespace"],function(Jupyter) { Jupyter.notebook.save_checkpoint(); }); window.parent.postMessage('jupytermessage','*'); setTimeout( runEvery10Sec, 1000 * 10 ); } // function keyDown(e){ // try { // e.preventDefault(); // var currKey=0, e=e||event||window.event; // currKey = e.keyCode||e.which||e.charCode; // if(currKey == 83 && (e.ctrlKey||e.metaKey)){ // console.log("点击了ctrl+s"); // console.log("开始发送消息了ctrl+s"); // window.parent.postMessage('jupytermessage','*'); // return true; // } // }catch (e) { // // } // } // document.onkeydown = keyDown; $(function(){ window.addEventListener('message', (e) => { console.log("触发了Parentwindow"); console.log(e); if(e){ if(e.data){ if(e.data==="Parentwindow"){ console.log("父窗口调我了"); } } } }); })