• 首页
  • 小学语文
  • 中学语文
  • 中学英语
  • 免费论文
  • 教学随笔
  • 学生作文
  • 综合考试
  • 试题教案
  • 育儿话题
  • 教学资源
  • 编程技术
  • 博客
  • 默认选中第二个按钮(取消)的conform

    日期:2003-03-04  地址:  作者:

    test.htm
    =====================================
    <html>
    <head>
    <title> New Document </title>
    <script language="javascript">
    /*************************************************
    功能:可以自己定制的confirm提示框,在IE6下测试通过

    这个confirm用还可以做好多扩展,比如修改背景的颜色,修改那个显示的图片,修改按钮的样式,可以打开象查找那样的非模态的窗口(需要IE5+),可以象定制网页一样随便你修改

    **************************************************/

    /*
    参数说明: strTitle confirm框的标题
       strMessage confirm框要显示的消息
       intType  confirm框的选中的类型1为选中YES,2为选中NO
       intWidth confirm框的宽度
       intHeight  confirm框的高度

    */
    function myConfirm(strTitle,strMessage,intType,intWidth,intHeight)
    {
     var strDialogFeatures = "status=no;center=yes;help=no;dialogWidth="+intWidth+";dialogHeight="+intHeight+";scroll=yes;resize=no";
     var args = new Array();
     args[args.length] = strTitle;
     args[args.length] = strMessage;
     args[args.length] = intType;
     var result = showModalDialog("myConfirm/myConfirm.htm",args,strDialogFeatures);
     return result;
    }
    function test()
    {
     var myConfirmResult = myConfirm("这里是标题","aaa",2,12,7)
     if(myConfirmResult)
      alert("您点了YES");
     else if(myConfirmResult == false)
      alert("您点了NO");
     else
      alert("您点了右上角的关闭");
    }
    </script>
    </head>

    <body>
    <input type="button" value="点我试试" onclick="test()">
    </html>

    myConfirm/myConfirm.htm
    =================================
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <script language="javascript">
    <!--
    var args = window.dialogArguments
    try{
     document.title = args[0]; //设置标题
    }catch(e)
    {
    //这里屏蔽了错误,防止万一调用的传递参数不足
    }

    //-->
    </script>
    <title></title>
    <style type="text/css">
    <!--
    body {
     margin-left: 0px;
     margin-top: 0px;
     background-color: menu;
     overflow: hidden;
     overflow-x:hidden;
        overflow-y:hidden;
    }
    -->
    </style>
    <script language="javascript">
    function init()
    {
     var args = window.dialogArguments
     try{
      message.innerHTML = args[1]; //设置提示的信息
      if(args[2] == 1)    //设置按钮的选中状态
       ok.focus(); 
      else
       cancel.focus();
     }catch(e)
     {
     //这里屏蔽了错误,防止万一调用的传递参数不足
     }
     ok.attachEvent("onclick",okClick); //设置YES按钮的事件处理函数
     cancel.attachEvent("onclick",cancelClick);//设置NO按钮的事件处理函数
    }
    function okClick()//YES按钮的事件处理函数
    {
      window.returnValue = true;
      window.close();
    }
    function cancelClick()//NO按钮的事件处理函数
    {
      window.returnValue = false
      window.close();
    }
    window.attachEvent("onload",init)
    </script>
    </head>

    <body>
    <table width="100%"  border="0" cellspacing="5">
      <tr>
        <td><div align="center">
          <img src="images/ico.gif" width="33" height="32"> </div></td>
        <td><div align="left" id="message"></div></td>
      </tr>
      <tr>
        <td>
          <div align="right">
            <input name="ok" type="button" id="ok" value="  确定  ">   
          </div></td>
        <td>
          <div align="left">
            <input name="cancel" type="button" id="cancel" value="  取消  ">
          </div></td>
      </tr>
    </table>
    </body>
    </html>

    用到的一个图片如下:


    有点麻烦,如果你不介意用VBscript的话还是用VBscript简单

    msgbox("aaa?",257)

    对 默认选中第二个按钮(取消)的conform 文章的评论    [查看网友评论]

    验证码:
    匿名发表: