Open ihtml5 opened 7 years ago
页面始终在一个窗口中打开
var mainWin = null; // window.open有窗口菜单配置项时,为新窗口打开,否则是标签页打开 function newFullscreenWindow(action, name) { if (mainWin == undefined || mainWin == null || mainWin.closed) { mainWin = window.open(action, "_blank"); mainWin.moveTo(0, 0); mainWin.resizeTo(screen.width + 20, screen.height); mainWin.focus(); console.log(mainWin.document); } else { mainWin.close(); mainWin = window.open(action, "_blank"); mainWin.moveTo(0, 0); mainWin.resizeTo(screen.width + 20, screen.height); mainWin.focus(); mainWin.document.location.reload(); } } // 事件代理,拦截链接点击默认行为,改为新窗口打开 $('table').on('click',function(event) { if(event.target.tagName === 'A') { event.preventDefault(); newFullscreenWindow(event.target.href); } });
用途
页面始终在一个窗口中打开
Code