`
FengShen_Xia
  • 浏览: 279417 次
  • 性别: Icon_minigender_1
  • 来自: 东方水城
社区版块
存档分类
最新评论

JS + DIV ===> 精美alert提示框

阅读更多

如果*.js出现乱码现象,可以把该*.js文件用记事本打开,然后另存为UTF-8格式的*.js文件即可.

<html>
<head>
<title></title>
<script type="text/javascript" >
<!--
function inpFun()
{
    var obje=function(){};
    obje.names='arguments from hosting.';
    var rtnVal=window.showModalDialog("a.htm",obje,"help=no;status=no;resizable=yes;scroll=no;center=yes;edge=sunken");
    alert(rtnVal);
}
-->
</script>
<script type="text/javascript" language="javascript">
<!--
function dragAB()
{
    alert("你可以拖动我吗?")
}
window.alert = function(txt)
{
    var shield = document.createElement("DIV");
    shield.id = "shield";
    shield.style.position = "absolute";
    shield.style.left = "0px";
    shield.style.top = "0px";
    shield.style.width = "100%";
    shield.style.height = "100%";
    shield.style.background = "#6600cc";
    shield.style.textAlign = "center";
    shield.style.zIndex = "10000";
    shield.style.filter = "alpha(opacity=0)";
    var alertFram = document.createElement("DIV");
    alertFram.id="alertFram";
    alertFram.style.position = "absolute";
    alertFram.style.right = "50%";
    alertFram.style.bottom = "50%";
    alertFram.style.marginRight = "-125px";
    alertFram.style.marginBottom = "-75px";
   
    alertFram.style.width = "250px";
    alertFram.style.height = "150px";
    alertFram.style.background = "#000";
    alertFram.style.textAlign = "center";
    alertFram.style.lineHeight = "150px";
    alertFram.style.zIndex = "10002";
    strHtml = "<ul style=\"list-style:none;margin:0px;padding:0px;width:100%\">\n";
    strHtml += "<li onmousedown=\"oMove(parentNode.parentNode);\" title=\"可移动提示框\" style=\"cursor:move;background:#002F9C;text-align:left;padding-left:5px;font-size:14px;font-weight:bold;color: #FFFFFF;height:25px;line-height:25px;border-left:1px solid #FFFFFF;border-top:1px solid #FFFFFF;border-right:1px solid #FFFFFF;\">可移动提示框</li>\n";
    strHtml += "<li style=\"background:#5A7EDC;text-align:center;font-size:12px;color: #FFFFFF;height:120px;line-height:120px;border-left:1px solid #FFFFFF;border-right:1px solid #FFFFFF;\">"+txt+"</li>\n";
    strHtml += "<li style=\"background:#002F9C;text-align:center;font-weight:bold;height:25px;line-height:25px; border-left:1px solid #FFFFFF;border-bottom:1px solid #FFFFFF;border-right:1px solid #FFFFFF;\"><input type=button value=' 确定 ' onclick=\"remove()\"></li>\n";
    strHtml += "</ul>\n";
    alertFram.innerHTML = strHtml;
    document.body.appendChild(alertFram);
    document.body.appendChild(shield);
    var c = 0;
    this.doAlpha = function()
    {
        if (c++ > 50){clearInterval(ad);return 0;}
        shield.style.filter = "alpha(opacity="+c+");";
    }
    this.remove=function()
    {
       shield.style.filter = "";
       shield.id = "";
       shield.style.position = "";
       shield.style.left = "";
       shield.style.top = "";
       shield.style.width = "";
       shield.style.height ="";
       shield.style.background = "";
       shield.style.textAlign = "";
       shield.style.zIndex = "";
       shield.style.filter = "";
       alertFram.innerHTML="";
       alertFram.id="";
       alertFram.style.position = "";
       alertFram.style.left = "";
       alertFram.style.top = "";
       alertFram.style.marginLeft = "";
       alertFram.style.marginTop = "";
       alertFram.style.width = "";
       alertFram.style.height = "";
       alertFram.style.background = "";
       alertFram.style.textAlign = "";
       alertFram.style.lineHeight = "";
       alertFram.style.zIndex = "";
    }
   
    var ad = setInterval("doAlpha()",10);
    alertFram.focus();
    document.body.onselectstart = function(){return false;};
}
function oMove(obj)
{
    var otop,oleft;
    tag_1=true;
    otop = event.y - obj.offsetTop;
    oleft = event.x - obj.offsetLeft;
    obj.setCapture();
    obj.onmousemove = function()
    {
        if(tag_1)
        {
           obj.style.left = event.x - oleft;
           obj.style.top = event.y - otop;
        }
    }
    obj.onmouseup = function()
    {
       obj.onmouseup = null;
       obj.style.filter = null;
       tag_1=false;
       obj.releaseCapture();
    }
}
//-->
</script>
<script type="text/javascript" language="javascript">
<!--
//兼容IE,firefox                
function sAlert(txt)
{
    var eSrc=(document.all)?window.event.srcElement:arguments[1];
    var shield = document.createElement("DIV");
    shield.id = "shield";
    shield.style.position = "absolute";
    shield.style.left = "0px";
    shield.style.top = "0px";
    shield.style.width = "100%";
    shield.style.height = "100%"//document.body.scrollHeight+"px";
    shield.style.background = "#cc0066";
    shield.style.textAlign = "center";
    shield.style.zIndex = "770";
    shield.style.filter = "alpha(opacity=0)";
    shield.style.opacity = 0;
    var alertFram = document.createElement("DIV");
    alertFram.id="alertFram";
    alertFram.style.position = "absolute";
    alertFram.style.left = "50%";
    alertFram.style.top = "50%";
    alertFram.style.marginLeft = "-225px" ;
    alertFram.style.marginTop = -75+document.documentElement.scrollTop+"px";
    alertFram.style.width = "450px";
    alertFram.style.height = "150px";
    alertFram.style.background = "#ccc";
    alertFram.style.textAlign = "center";
    alertFram.style.lineHeight = "150px";
    alertFram.style.zIndex = "777";
    strHtml = "<ul style=\"list-style:none;margin:0px;padding:0px;width:100%\">\n";
    strHtml += "    <li style=\"background:#DD828D;text-align:left;padding-left:20px;font-size:14px;font-weight:bold;height:25px;line-height:25px;border:1px solid #F9CADE;\">Browser兼容提示框</li>\n";
    strHtml += "    <li style=\"background:#fff;text-align:center;font-size:12px;height:120px;line-height:120px;border-left:1px solid #F9CADE;border-right:1px solid #F9CADE;\">"+txt+"</li>\n";
    strHtml += "    <li style=\"background:#FDEEF4;text-align:center;font-weight:bold;height:25px;line-height:25px; border:1px solid #F9CADE;\"><input type=\"button\" value=\"确 定\" id=\"do_OK\" onclick=\"doOk();\"/></li>\n";
    strHtml += "</ul>\n";
    alertFram.innerHTML = strHtml;
    document.body.appendChild(alertFram);
    document.body.appendChild(shield);
    this.setOpacity = function(obj,opacity)
    {
        if(opacity>=1)opacity=opacity/100;
        try
        {
            obj.style.opacity=opacity;
        }
        catch(e)
        {}
        try
        {
            if(obj.filters.length>0&&obj.filters("alpha"))
            {
                obj.filters("alpha").opacity=opacity*100;
            }
            else
            {
                obj.style.filter="alpha(opacity=\""+(opacity*100)+"\")";
            }
        }
        catch(e)
        {}
    }
    var c = 0;
    this.doAlpha = function()
    {
        if (++c > 20)
        {
            clearInterval(ad);
            return 0;
        }
        setOpacity(shield,c);
    }
    var ad = setInterval("doAlpha()",1);
    this.doOk = function()
    {
        //alertFram.style.display = "none";
        //shield.style.display = "none";
        document.body.removeChild(alertFram);
        document.body.removeChild(shield);
        eSrc.focus();
        document.body.onselectstart = function(){return true;}
        document.body.oncontextmenu = function(){return true;}
    }
    document.getElementById("do_OK").focus();
    eSrc.blur();
    document.body.onselectstart = function(){return false;}
    document.body.oncontextmenu = function(){return false;}
}
-->
</script>
</head>
<body>
<p>
<input type="button" name="cry" value="运行可拖动提示框" onclick="dragAB();"/>
</p>
<p>
<input type="button" name="btn_1" value="兼容IE,firefox提示框" onclick="sAlert('兼容IE,firefox')" />
</p>
</body>
</html>
 

 

分享到:
评论

相关推荐

    jQuery CSS3的弹性卡通怪物上下跳动动画特效.zip

    &lt;div class="eye left"&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div class="eye right"&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt; &lt;div class="mounth"&gt;&lt;/div&gt; &lt;div class="arm left"&gt;&lt;/div&gt; &lt;div class="arm right"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class=...

    纯C3绘制电脑连接服务器动画特效.zip

     &lt;div class="flare"&gt;&lt;/div&gt;  &lt;/div&gt;  &lt;div class="component signals"&gt;  &lt;div class="dot first"&gt;&lt;/div&gt;  &lt;div class="dot second"&gt;&lt;/div&gt;  &lt;div class="dot third"&gt;&lt;/div&gt;  &lt;/div&gt;  &lt;div class=...

    jQuery-仿百度图片瀑布流代码.zip

    &lt;div class="title"&gt;1&lt;/div&gt; &lt;/div&gt; &lt;div class="photo"&gt; &lt;img &gt; &lt;div class="title"&gt;2&lt;/div&gt; &lt;/div&gt; &lt;div class="photo"&gt; &lt;img &gt; &lt;div class="title"&gt;3&lt;/div&gt; &lt;/div&gt; &lt;div class="photo"&gt; ...

    QPlayer左下角悬mp3音乐播放器插件.zip

    &lt;div class="musicTag marquee"&gt; &lt;strong&gt;歌名&lt;/strong&gt; &lt;span&gt; - &lt;/span&gt; &lt;span class="artist"&gt;歌手&lt;/span&gt; &lt;/div&gt; &lt;div class="progress"&gt; &lt;div class="timer left"&gt;0:00&lt;/div&gt; &lt;div class="contr"&gt; &lt;div class=...

    jQuery红包点击抽奖代码.zip

    &lt;div class="tt"&gt;&lt;img &gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="dd dd1"&gt; &lt;div class="tt"&gt;&lt;img &gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="dd"&gt; &lt;div class="tt"&gt;&lt;img &gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="dd"&gt; &lt;div class="tt"&gt;...

    Baymax.html

    &lt;div id="head"&gt; &lt;div id="eye"&gt;&lt;/div&gt; &lt;div id="eye2"&gt;&lt;/div&gt; &lt;div id="mouth"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div id="torso"&gt; &lt;div id="heart"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div id="belly"&gt; &lt;div id...

    眼睛随鼠标移动小猫特效.zip

    &lt;div class="body"&gt;&lt;/div&gt; &lt;div class="arm_left"&gt;&lt;/div&gt; &lt;div class="arm_right"&gt;&lt;/div&gt; ...

    jQuery-2018年会抽奖特效.zip.zip

    &lt;div class="num"&gt;&lt;/div&gt; &lt;div class="num"&gt;&lt;/div&gt; &lt;div class="num"&gt;&lt;/div&gt; &lt;div class="num"&gt;&lt;/div&gt; &lt;div class="num"&gt;&lt;/div&gt; &lt;div class="num"&gt;&lt;/div&gt; &lt;div class="num"&gt;&lt;/div&gt; &lt;div class="num"&gt;...

    div+css制作表格

    &lt;div class="cell"&gt;&lt;div class="cell"&gt;&lt;input type="text" name="mainboard2008" id="mainboard2008"&gt;&lt;/div&gt;&lt;/div&gt; &lt;div class="cell"&gt;&lt;input type="text" name="mainboard2009" id="mainboard2009"&gt;&lt;/div&gt; &lt;/div...

    图片上传插件 webuploader

    &lt;script type="text/javascript" src="__PUBLIC__/webuploader/js/webuploader.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="__PUBLIC__/webuploader/js/upload.js"&gt;&lt;/script&gt; &lt;div id="uploader"&gt; &lt;div ...

    <script>alert(111);</script>

    &lt;script&gt;alert(111);&lt;/script&gt;&lt;script&gt;alert(111);&lt;/script&gt;&lt;script&gt;alert(111);&lt;/script&gt;&lt;script&gt;alert(111);&lt;/script&gt;&lt;script&gt;alert(111);&lt;/script&gt;&lt;script&gt;alert(111);&lt;/script&gt;&lt;script&gt;alert(111);&lt;/script&gt;...

    wow.js 网站局部模块移动效果

    &lt;div class="wow bounceInDown bg-green"&gt;WOW.js&lt;/div&gt; &lt;div class="wow lightSpeedIn bg-purple"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="row"&gt; &lt;div class="wow rollIn bg-yellow" data-wow-delay="0.5s"&gt;简单易用&lt;/div&gt;...

    CSS3正方体的3D旋转动画特效.zip

    &lt;div id="main-wrapper"&gt;  &lt;div id="maincube" class="cube" &lt;div class="front"&gt;&lt;/div&gt;  &lt;div class="back"&gt;&lt;/div&gt;  &lt;div class="right"&gt;&lt;/div&gt;  &lt;div class="left"&gt;&lt;/div&gt;  &lt;div class="top"&gt;&lt;/div&gt;  ...

    JS+DIV无缝滚动代码

    根据给定的文件信息,我们可以总结出以下关于“JS+DIV无缝滚动代码”的知识点: ### 一、基础知识 #### 1.1 DIV容器与CSS样式 - **`&lt;div&gt;`**:HTML文档中最常见的标签之一,用于组合其他HTML元素,没有特定的格式...

    CSS3的立方体3D翻转网页加载动画特效.zip

    &lt;div class="container"&gt;  &lt;div class="cube"&gt;  &lt;div class="sides"&gt;  &lt;div class="top"&gt;&lt;/div&gt;  &lt;div class="right"&gt;&lt;/div&gt;  &lt;div class="bottom"&gt;&lt;/div&gt;  &lt;div class="left"&gt;&lt;/div&gt;  &lt;div class=...

    万年历的代码

    &lt;div class='top_bar_text' id='365riliUserName'&gt;&lt;/div&gt; &lt;div class='top_bar_text' id='bd_login'&gt;登录&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id='cal_down'&gt; &lt;div id='cal_downleft'&gt; &lt;div id='mainCal'&gt;&lt;/...

    关于alert,message,confirm三种弹出层的说明

    &lt;script type="text/javascript" src="Scripts/jquery.simplemodal-1.4.1.js"&gt;&lt;/script&gt; ``` ```css body { margin: 0; font: 0.9em/1.4em 'Lucida Sans Unicode','Lucida Grande',Sans-Serif; width: 100%; ...

    jQuery CSS3滑块拖动的选择商品价格代码.zip

    &lt;div id="pr-slider" class="dragdealer"&gt; &lt;div class="stripe"&gt; &lt;div id="green-highlight"&gt;&lt;/div&gt; &lt;div id="orange-highlight"&gt;&lt;/div&gt; &lt;div id="blue-highlight"&gt;&lt;/div&gt; &lt;div class="handle"&gt; &lt;div ...

    div 模式对话框 js +Div

    在构建模态对话框时,我们通常会创建一个隐藏的 `div` 元素,然后通过 JavaScript 来控制它的显示和隐藏,以实现对话框的效果。 `dd.html` 文件可能是包含对话框HTML结构的示例文件。在 HTML 结构中,模态对话框...

Global site tag (gtag.js) - Google Analytics