头闻号

山东奥纳化工有限公司

填充剂|脱模剂|其他合成材料助剂|其他未分类|增塑剂|阻垢剂

首页 > 新闻中心 > 科技常识:项目中打开新窗口的3种方式
科技常识:项目中打开新窗口的3种方式
发布时间:2023-02-01 10:29:27        浏览次数:6        返回列表

今天小编跟大家讲解下有关项目中打开新窗口的3种方式 ,相信小伙伴们对这个话题应该有所关注吧,小编也收集到了有关项目中打开新窗口的3种方式 的相关资料,希望小伙伴们看了有所帮助。

1.使用iframe(注意Iframe的高度默认150px,如果要改变iframe的高度,只能设置成具体的像素值,不能是百分比)

2.使用window.open()直接打开外部窗口,在外部窗口中处理完成所有的操作后回到原来的页面,原来的页面出现一个确认是否完成操作的弹框。点击确认或者“cancel”之后接着调用其他的接口。

3.使用window.open()在当前窗口打开另一个窗口,在新开窗口中操作完成之后,关闭该窗口,在当前窗口中监听新窗口什么时候关闭,一旦检测到窗口关闭就执行回调。使用这种方式需要考虑浏览器的跨域问题,在ie上如果使用window.open()打开跨域了的窗口,window.open()是获取不到window对象的。

detectCreditCardFilledOut: (callback, url, openWin) => { let creditCarWin = null; let s = null; const stopF = () => { clearInterval(s); creditCarWin = null; s = null; callback(); }; const checkCloseWindowOrNot= () => { if (creditCarWin != null && creditCarWin.closed) { stopF(); } }; const openCreditCard = () => { try { creditCarWin = openWin(url, 'CreditCard'); creditCarWin.focus(); runF(); } catch (e) { Util.NotificationUtil('error', { description: lang.openWindowError }) } }; const runF = () => { s = setInterval(checkCloseWindowOrNot, 500); }; openCreditCard();},

来源:爱蒂网