养浩然之气,做博学之人
项目框架用了iframe,所以在用layer时,默认layer.open弹出的窗口只能在iframe子窗口区域显示。若想让layer在父窗口或者说框架的最顶层显示,可以用top.layer.open或者parent.layer.open,但是没反应。需要在父页面中引入layer.js文件,导入后就能正常显示在父窗口页面了。
top和parent是浏览器的内置对象,top表示最顶层容器,parent表示父容器。
(1)普通用法:在当前页面引入Layer相关css和js文件
layer.open({ type: 2, content: 'iframeC.html', shade: false, success: function(layero, index) { top.layerFrameConfig.iframeC = { layer_index: index, layer_layero: layero } }});
(2)top.layer.open用法:需在最高层页面引入Layer相关css和js文件
top.layer.open({ type: 2, content: 'iframeD.html', shade: false, success: function(layero, index) { top.layerFrameConfig.iframeD = { layer_index: index, layer_layero: layero } }});
(3)parent.layer.open用法:需在父页面引入Layer相关css和js文件
parent.layer.open({ type: 2, content: 'iframeE.html', shade: false, success: function(layero, index) { top.layerFrameConfig.iframeE = { layer_index: index, layer_layero: layero } }});
一般常用top.layer.open方式:
(1)最外层页面引入Layer相关js和css
(2)本页面完成top.layer.open方法
编辑:孙小北
本文地址: https://www.xiaowangyun.com/wyblog/detail/?id=198
版权归属: www.xiaowangyun.com 转载时请以链接形式注明出处
0 条评论