系统弹出窗口的时候能否让确定、取消的按钮自定义呢?例如换成yes\no??<form name="form1" action="http://cn.yahoo.com">
<input type="button" value="删除" onclick="javascript:if(confirm('确定删除?')){submit()}" />
</from>

解决方案 »

  1.   


    好像不能~·confirm是根据浏览器语言定义的~·你浏览器要是英文的那就弹出yes/no要不你就用层写个模拟~·
      

  2.   

    confirm 是浏览器提供滴对话窗口,样式和按钮文字是固定滴,无法修改!很多人问过这个问题,答案就是使用自定义提示框,
    原理很简单,底下一个 div 做遮罩,上面一个 div 做提示框,至于按钮样式可以完全随心所欲!俺参考以下代码实现了自定义 confirm
    http://www.leigeber.com/2008/04/custom-javascript-dialog-boxes/
      

  3.   

    网上有现在的组件,自己写的话比较麻烦,而且样式不容易控制还要考虑浏览器兼容:
    http://www.ajaxbbs.net/post/product/ymPrompt3.1.html
      

  4.   


    <style type="text/css">
    .opaqueLayer{display:none;position:absolute;top:0px;left:0px;opacity:0.6;filter:alpha(opacity=60);background-color: #000000;z-Index:1000;}
    </style>
    <script type="text/javascript">
    function getBrowserHeight() {
    var intH = 0;
    var intW = 0;if(typeof window.innerWidth == 'number' ) {
    intH = window.innerHeight;
    intW = window.innerWidth;
    }
    else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
    intH = document.documentElement.clientHeight;
    intW = document.documentElement.clientWidth;
    }
    else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
    intH = document.body.clientHeight;
    intW = document.body.clientWidth;
    }
    return { width: parseInt(intW), height: parseInt(intH) };
    }function setLayerPosition() {
    var shadow = document.getElementById('shadow');
    var question = document.getElementById('question');var bws = getBrowserHeight();
    shadow.style.width = bws.width + 'px';
    shadow.style.height = bws.height + 'px';
    question.style.left = parseInt((bws.width - 350) / 2)+ 'px';
    question.style.top = parseInt((bws.height - 200) / 2)+ 'px';
    shadow = null;
    question = null;
    }    function showLayer() {
        setLayerPosition();
        
        var shadow = document.getElementById('shadow');
        var question = document.getElementById('question');
        
        shadow.style.display = 'block';
        question.style.display = 'block';
        
        shadow = null;
        question = null;
        }
        
        function hideLayer() {
        var shadow = document.getElementById('shadow');
        var question = document.getElementById('question');
        
        shadow.style.display = 'none';
        question.style.display = 'none';
        
        shadow = null;
        question = null;
        }window.onload=function(){
      window.onresize = setLayerPosition;
    }
    </script>
    <iframe id="shadow" class="opaqueLayer" style="border:0;" src="about:blank"></iframe>
    <input type="button" value="click" onclick="showLayer();">
    <div id="question" style="width:300px;height:120px;padding:20px;display:none;position:absolute;z-index:1001;background:#CCC;border:10px solid #999;">
            <input type="button" value="按钮1234">
            <input type="button" value="取消关闭" onclick="hideLayer()">
    </div>
      

  5.   

    或者我的中文操作系统如果安装英文的浏览器,应该看到的就是yes、no是吗
      

  6.   

    英文操作系统看到是OK Cancel, 如果用VBS的megbox可以设置yes no