首页 > 代码库 > 点击弹出层
点击弹出层
<html> <head> <title>点击按钮,弹出一个层</title> <script> var docEle = function() { return document.getElementById(arguments[0]) || false; } function openNewDiv(_id) { var m = "mask"; if (docEle(_id)) document.removeChild(docEle(_id)); if (docEle(m)) document.removeChild(docEle(m)); // 新激活图层 var newDiv = document.createElement("div"); newDiv.id = _id; newDiv.style.position = "absolute"; newDiv.style.zIndex = "9999"; newDiv.style.width = "300px"; newDiv.style.height = "150px"; newDiv.style.top = "50%"; newDiv.style.left = (parseInt(document.body.scrollWidth) - 300) / 2 + "px"; // 屏幕居中 newDiv.style.background = "#EFEFEF"; newDiv.style.border = "1px solid #860001"; newDiv.style.padding = "5px"; newDiv.innerHTML +="<br/><br/><br/><span> 请在新窗口完成支付!</span>"; document.body.appendChild(newDiv); // mask图层 var newMask = document.createElement("div"); newMask.id = m; newMask.style.position = "absolute"; newMask.style.zIndex = "1"; newMask.style.width = document.body.scrollWidth + "px"; newMask.style.height = document.body.scrollHeight + "px"; newMask.style.top = "0px"; newMask.style.left = "0px"; newMask.style.background = "#000"; newMask.style.filter = "alpha(opacity=20)"; newMask.style.opacity = "0.20"; document.body.appendChild(newMask); // 关闭mask和新图层 var newA = document.createElement("a"); newA.href = "#"; newA.innerHTML = "点此继续"; newA.onclick = function() { document.body.removeChild(docEle(_id)); document.body.removeChild(docEle(m)); window.open (‘http://www.17rice.com‘) return false; } newDiv.appendChild(newA); } </script> </head> <body> <input type="button" value="http://www.mamicode.com/ 点这里 " onclick="openNewDiv(1)" /> </body> </html>
点击弹出层
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。