Is there a JavaScript alert that doesn't pause the script?

后端 未结 6 1110
甜味超标
甜味超标 2020-11-28 07:51

I\'m looking for something like alert(), but that doesn\'t \"pause\" the script.

I want to display an alert and allow the next command, a form sub

6条回答
  •  迷失自我
    2020-11-28 08:01

    98% of the time there is a way to move your message script so that it calls after everything else executes. For that other 2%, I like to use floating divs that look something like this. You can then change your CSS to match the style of your application/website or to make it look more like a standard windows popup.

    /*HTML*/
    
    
    /*javaScript*/
    function openWindow(id){
    "use strict";
    document.getElementById(id).style.visibility = 'visible'; 
    }
    function closeWindow(id){
    "use strict";
    document.getElementById(id).style.visibility = 'hidden'; 
    }
    function myMsgBox(TITLE,MESSAGE) {
    "use strict";   
    document.getElementById("msgBox").innerHTML = "\"[close]\"

    " + TITLE + "


    " + MESSAGE + "

    "; openWindow("msgBox"); } /*CSS*/ .floatingDiv { position:absolute; z-index:10000; left:33%; top:250px; width:33%; background-color:#FFF; min-width:217px; text-align: left; border-radius: 10px 10px; border:solid; border-width:1px; border-color:#000; vertical-align:top; padding:10px; background-image: -ms-linear-gradient(top, #CCCCCC 0%, #FFFFFF 25px, #FFFFFF 100%); background-image: -moz-linear-gradient(top, #CCCCCC 0%, #FFFFFF 25px, #FFFFFF 100%); background-image: -o-linear-gradient(top, #CCCCCC 0%, #FFFFFF 25px, #FFFFFF 100%); background-image: -webkit-linear-gradient(top, #CCCCCC 0%, #FFFFFF 25px, #FFFFFF 100%); background-image: linear-gradient(to bottom, #CCCCCC 0%, #FFFFFF 25px, #FFFFFF 100%); box-shadow:3px 3px 5px #003; filter: progid:DXImageTransform.Microsoft.Shadow(color='#000033', Direction=145, Strength=3); }

提交回复
热议问题