js頁面彈窗
1、html元素
<div id="light" class="white_content">
<div id="lightHeader"><span id='xxxx'>詳細資訊 </span>
<span id="closeSpan"><a href="javascript:void(0)" onclick="closeDiv()">X</a></span></div>
<div id="lightContent"></div>
</div>
2、css樣式
/**懸浮**/
.white_content {
display: none;
position: absolute;
top: 25%;
left: 25%;
width: 50%;
height: 50%;
padding: 0px;
border: 2px solid gray;
background-color: white;
z-index: 1002;
}
#lightHeader{
height:30px;
font-size: 14px;
background-color: rgb(99,177,223);
line-height: 30px;
}
#xxxx{
color:white;
padding-left: 5px;
font-weight: bold;
}
#closeSpan{
position: absolute;
right: 15px;
top: 0;
}
#closeSpan a{
text-decoration: none;
color: white;
}
#lightContent{
padding: 5px;
overflow: auto;
}
/**end懸浮**/
3、js
//展示資訊
function showInfo(event){
var obj = event.srcElement ? event.srcElement:event.target;
//var text = obj.getAttribute("cont");
var text2 = obj.innerHTML;
//console.log(text);
//alert(text2);
showDiv(text2);
//alert(text);
}
function showDiv(title){
var procbg = document.createElement("div"); //首先建立一個div
procbg.setAttribute("id","mybg"); //定義該div的id
procbg.style.background = "#000000";
procbg.style.width = "100%";
procbg.style.height = "100%";
procbg.style.position = "fixed";
procbg.style.top = "0";
procbg.style.left = "0";
procbg.style.zIndex = "500";
procbg.style.opacity = "0.6";
procbg.style.filter = "Alpha(opacity=70)";
//背景層加入頁面
document.body.appendChild(procbg);
document.body.style.overflow = "hidden"; //取消滾動條
var Idiv = document.getElementById("light");
Idiv.style.display = "block";
//以下部分要將彈出層居中顯示
Idiv.style.left=(document.documentElement.clientWidth-Idiv.clientWidth)/2+document.documentElement.scrollLeft+"px";
Idiv.style.top =(document.documentElement.clientHeight-Idiv.clientHeight)/2+document.documentElement.scrollTop-50+"px";
document.getElementById('light').style.display='block';
var height = $("#light").height();
var width = $("#light").width();
$("#lightContent").css('height', (height - 42) + 'px');
$("#lightContent").css('width', (width -10) + 'px');
/*$("#lightContent").height(height - 35);
$("#lightContent").width(width);*/
//alert(title);
$("#lightContent").empty();
$("#lightContent").append('<pre>' + title + ' </pre>');
}
function closeDiv(){
var Idiv=document.getElementById("light");
Idiv.style.display="none";
document.body.style.overflow = "auto"; //恢復頁面滾動條
var body = document.getElementsByTagName("body");
var mybg = document.getElementById("mybg");
body[0].removeChild(mybg);
}
相關文章
- 頁面彈窗處理方案
- js為showModalDialog()彈出視窗的頁面傳值JS
- 關於頁面中彈窗的定位問題
- JSP/HTML頁面彈出框JSHTML
- h5單頁面彈出彈窗背景滾動問題H5
- js關閉當前頁面視窗的問題JS
- 技術日誌 - Dcat Admin 使用 - 在列表頁面新增彈窗操作
- 簡單的網頁彈窗陷阱網頁
- iframe裡面的頁面呼叫父視窗,左右視窗js函式的方法JS函式
- svelte-layer 基於svelte.js網頁pc端彈窗元件JS網頁元件
- JS彈出視窗視窗的位置和大小JS
- 一行js彈窗程式碼就能設計漂亮的彈窗廣告JS
- 網頁右下角彈窗詳解網頁
- javascript網頁右下角彈窗效果JavaScript網頁
- 關閉網頁彈出提示視窗網頁
- js 彈窗jquery.tools.min.js 實現JSjQuery
- vue頁面有彈層,禁止頁面滾動Vue
- Spring3MVC提交彈出視窗表單後,自動返回父視窗的列表頁面SpringMVC
- 瀏覽器彈出小頁面瀏覽器
- js具有跟隨彈性效果的網頁右下角視窗程式碼JS網頁
- js漸變彈出視窗和關閉視窗效果JS
- js頁面跳轉JS
- easyui 中iframe巢狀頁面,大彈窗自適應居中的解決方法。$('#win').window()UI巢狀
- 在框架頁中彈出新視窗提供列印功能框架
- js頁面跳轉的問題(跳轉到父頁面、最外層頁面、本頁面)JS
- js實現在彈出視窗中重新整理主視窗JS
- 模式視窗頁面不更新的問題模式
- js/jquery禁止頁面回退JSjQuery
- JSP註冊頁面JS
- SSH之jsp頁面JS
- js——頁面回到頂部JS
- js重新整理頁面JS
- JS窗體彈出問題輸入答案_promptJS
- iView之Modal(一級彈窗和二級彈窗)View
- Jquery彈窗元件jQuery元件
- layui 子彈窗獲取父頁面的引數傳參UI
- WPF 自定義MessageBox 彈窗提示 彈窗載入
- 專案實戰:彈出廣告任意頁面展示