Browser Alert Styling [duplicate]

半世苍凉 提交于 2019-12-24 11:34:03

问题


I currently have a contact form that when completed triggers a browser alert/popup but i would like to style the popup to be more like a modal. So the popup would be centred & overlaid on the page with a dark transparent background that fades away when clicked - is this possible?

Here is my current script triggering the popup alert: http://jsfiddle.net/xf4C6/

function fcheckf(){
var x = document.getElementById('check').value;
if(x == 0)
{
    return false;
} 
else
{
     alert("Your message has been sent! Thank you for getting in touch.");
}
 }

回答1:


Oki doki heres my answer:

HTML

<div id="popup" style="width:250px;height:250px;background-color:rgba(255,255,255,0.5);border:3px solid black;display:none;z-index:999;position:absolute;top:50%;left:50%;margin-left:-125px;margin-top:-125px;">
        <div style="width:230px;height:230px;margin-left:10px;margin-top:10px;background-color:#FFFFFF;">
            Thank you for submitting your details<p>
            <div onclick="document.getElementById('popup').style.diplay='none';" style="margin-left:auto;margin-right:auto;width:75px;height:30px;background-color:#000000;cursor:hand;">
                Close
            </div>
        </div>
</div>

Javascript

Change

alert("Your message has been sent! Thank you for getting in touch.");

to

document.getElementById("popup").style.display="block";



回答2:


you can use jquery ui dialog

see documentation



来源:https://stackoverflow.com/questions/23417498/browser-alert-styling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!