--更新——我读了很多关于这个主题的文章,尝试了一些脚本,需要帮助来找出你能做什么或不能做什么。社区回答了所有问题,以下是一个很好的起点。(答案摘自以下社区,谢谢)
不能覆盖默认的警报样式。它是由你的客户制作的(如chrome firefox等)
您可以改用jquery。而不是使用如下脚本:
函数检查域输入{
var domain_val=document.getelementsbyname('domain');
if(域值[0].value.length>0{
回归真实;
}
警报('请输入要搜索的域名');
返回false;
}
这使得客户端(firefox chrome等)产生一个警告框。
2b.如果需要在事件加载jquery alertbox上发生一些事情,您可以告诉代码,使其变得漂亮:(由jonathan payne回答,由jonathan payne创建。谢谢)

<link rel="stylesheet" href="http://code.jquery.com/ui/1.8.21/themes/base/jquery-ui.css" type="text/css" media="all" />

<div onclick="check_domain_input()">Click</div>

<div id="dialog" title="Attention!" style="display:none">
    Please enter a domain name to search for.
</div>

<script>
    function check_domain_input()
    {
        $( "#dialog" ).dialog(); // Shows the new alert box.

        var domain_val = document.getElementsByName('domain');

        if (domain_val[0].value.length > 0)
        {
            return true;
        }

        $( "#dialog" ).dialog();

        return false;
    }
</script>

在这里查看jsfiddle:http://jsfiddle.net/8cypx/12/

最佳答案

尝试位于此处的jQuery UIhttp://jqueryui.com/demos/dialog/
它们有一个主题滚轮,您可以在其中设置对话框和模式框的样式。
--编辑——
回答你的第二个问题。
在这里查看jsfiddle:http://jsfiddle.net/8cypx/12/

<link rel="stylesheet" href="http://code.jquery.com/ui/1.8.21/themes/base/jquery-ui.css" type="text/css" media="all" />

<div onclick="check_domain_input()">Click</div>

<div id="dialog" title="Attention!" style="display:none">
    Please enter a domain name to search for.
</div>

<script>
    function check_domain_input()
    {
        $( "#dialog" ).dialog(); // Shows the new alert box.

        var domain_val = document.getElementsByName('domain');

        if (domain_val[0].value.length > 0)
        {
            return true;
        }

        $( "#dialog" ).dialog();

        return false;
    }
</script>

·

07-24 18:19
查看更多