Home >Web Front-end >HTML Tutorial >弹出居中iframe窗口,点击其它位置消失_html/css_WEB-ITnose

弹出居中iframe窗口,点击其它位置消失_html/css_WEB-ITnose

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-21 09:00:111340browse

1.html

<a class="info_show" href="javascript:;" onclick="detail(22)" >弹出详情</a><br /><iframe id="myFrameId" src="https://www.baidu.com" name="myFrameName" scrolling="no" frameborder="0"></iframe>

2.css

#myFrameId{	width:800px;	height:600px;	position: absolute;	display:none;}

3.js

function detail(id){    $('#myFrameId').attr('src','https://www.baidu.com');    $('#myFrameId').show();    iframe_height = $(window).height()-600;    iframe_width = $(document).width()-800;    iframe_height>0?iframe_height=(iframe_height/2):iframe_height=0;    iframe_width>0?iframe_width=(iframe_width/2):iframe_width=0;    $('#myFrameId').css('top',iframe_height);    $('#myFrameId').css('left',iframe_width);}$(document).on("click", function(e){    console.log('123');    $('#myFrameId').hide();});$(".myFrameId,.info_show").on("click", function(e){    console.log('456');    e.stopPropagation();});


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn