网站介绍
这是一个名为initOpen
的JavaScript函数,它接收一个URL参数。该函数的主要功能是在浏览器窗口中打开一个新的网页,并在页面上显示一个黑色半透明背景,同时在右下角添加一个关闭按钮。
功能说明
- 打印传入的URL参数。
- 获取浏览器窗口的可用宽度和高度。
- 计算详细信息部分的高度(
detail_h
)和宽度(detail_w
)。 - 构建HTML字符串,包括一个固定位置的黑色半透明背景、一个可点击的关闭按钮以及详细信息部分。
- 将构建好的HTML字符串插入到页面中。
代码示例
function initOpen(url){
console.log("url:"+url);
var win_w = window.screen.availWidth, win_h = window.screen.availHeight, html = '';
var detail_h = win_h - 100, detail_w = detail_h + detail_h/2;
html += '<div id="photo_detail_div" style="position:fixed;top:0;left:0;right:0;bottom:0;z-index:99;">';
html += '<div onclick="$(this).parent().remove()" style="position:absolute;top:0;left:0;right:0;bottom:0;background:#000000;opacity:0.7;"></div>';
html += '<div style="position:absolute;width:'+detail_w+'px;height:'+detail_h+'px;overflow-y:scroll;"></div>';
html += '</div>';
$('body').append(html);
}