Pre*_*ran 0 javascript iframe dojo popup
理想情况下,当我单击我的表中的一个操作项时,它显示"显示消息"点击它我需要一个弹出窗口而不使用window.alert或alert显示根据我的网站设计弹出
function showFailedWarning(){
dijit.byId('validationsForm').clearMessages();
dijit.byId('validationsForm').popup(alert("Upload Correct File "));
}
Run Code Online (Sandbox Code Playgroud)
您可以使用您想要的任何设计构建自己的弹出窗口.要么硬编码 HTML中的元素并设置display:none
为CSS中的容器,要么动态附加容器.
注意: 为什么我用innerHTML
它代替appendChild()
.
<button id="error">Click for error</button>
Run Code Online (Sandbox Code Playgroud)
document.getElementById('error').onclick = function (event) {
event.preventDefault();
/*Creating and appending the element */
var element = '<div id="overlay" style="opacity:0"><div id="container">';
element += "<h1>Title</h1><p>Message</p>";
element += "</div></div>";
document.body.innerHTML += (element);
document.getElementById('overlay').style.display = "block";
/* FadeIn animation, just for the sake of it */
var fadeIn = setInterval(function () {
if (document.getElementById('overlay').style.opacity > 0.98) clearInterval(fadeIn);
var overlay = document.getElementById('overlay');
overlay.style.opacity = parseFloat(overlay.style.opacity, 10) + 0.05;
console.log(parseFloat(overlay.style.opacity, 10));
}, 50);
};
Run Code Online (Sandbox Code Playgroud)
#overlay {
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
z-index:1000;
background-color: rgba(0, 0, 0, 0.5);
opacity:0;
display:none;
}
#container {
position:absolute;
top:30%;
left:50%;
margin-left:-200px;
width: 400px;
height:250px;
background-color:#111;
padding:5px;
border-radius:4px;
color:#FFF;
}
Run Code Online (Sandbox Code Playgroud)
您可以使用库jQuery UI
来实现您想要的:
<button id="error">Click for error</button>
Run Code Online (Sandbox Code Playgroud)
$('#error').click(function (event) {
event.preventDefault();
$('<div id="container"><h1>Error</h1><p>Message</p></div>').dialog({
title: "Error"
});
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4735 次 |
最近记录: |