精灵饭饭

layer弹框

  

官网http://layer.layui.com/

/!*
如果是页面层
*/
layer.open({
  type: 1,
  content: '传入任意的文本或html' //这里content是一个普通的String
});

layer.open({
  type: 1,
  content: $('#id') //这里content是一个DOM
});
//Ajax获取
$.post('url', {}, function(str){
  layer.open({
    type: 1,
    content: str //注意,如果str是object,那么需要字符拼接。
  });
});


/!*
如果是iframe层
*/
layer.open({
  type: 2,
  content: 'http://sentsin.com' //这里content是一个URL,如果你不想让iframe出现滚动条,你还可以content: ['http://sentsin.com', 'no']
});


/!*
如果是用layer.open执行tips层
*/
layer.open({
  type: 4,
  content: ['内容', '#id'] //数组第二项即吸附元素选择器或者DOM
});

-----------------------------------------------------

案例1:

1.html写

<a href="javascript:showProtocol()">xx协议</a>&raquo;</label>

<script type="text/javascript">
  function showProtocol(){
    layer.open({
      type: 2,
      title: '学校心育委大数据共享平台用户协议',
      shadeClose: true,
      shade: 0.8,
      area: ['50%', '90%'],
      content: ['<%=basePath%>/protocol.jsp','no']   //弹框加载第二个页面
    });
  }
</script>

2.html写

注意滚动条样式

#content{
  width: 98%;
  overflow-y: scroll;
  height: 98%;
  position: absolute;
}

posted on 2016-11-28 15:13  精灵饭饭  阅读(265)  评论(0编辑  收藏  举报