sciter 提示消息弹窗与自定义弹窗

<html>
  <head>
  <title>view.msgbox() variations</title>
<style></style>

<script type="text/tiscript">

  @click @on "#hello-world-1": {
    var r = view.msgbox(#alert,"Hello world!");
    stdout.println(r);        
  }
  @click @on "#hello-world-2": {
    var r = view.msgbox { type:#information,
                  content:"Hello world!",
                  caption:"Greeting:" };

    stdout.println(r);        
  }
  @click @on "#hello-world-3": {
    view.msgbox { type:#information,
                  content:"world!",
                  caption:"Hello",
                  onLoad: function(root){ stdout.printf("msgbox loaded with %s\n",root); },
                  onClose: function(root,buttonSym){ stdout.printf("msgbox closed with #%s\n",buttonSym); }
                };

  }

  @click @on "#hello-world-4": {
    var result = view.msgbox { type:#question,
                               content:"Is anybody out there?",
                               //buttons:[#yes,#no]
                                buttons:[
                                 {id:#yes,text:"Yes",role:"default-button"},
                                 {id:#cancel,text:"No",role:"cancel-button"}]                               
                               

                               
                             };
    stdout.printf("msgbox result: #%s\n",result);
  }

  @click @on "#hello-world-5": {
    var result = view.msgbox { type:#error,
                               content:"<b #name></b> something is terribly\nwrong under your Sun.<br>Let's fix it!",
                               onLoad: function(root){ root.$(#name).text = "World!"; }
                             };

  }

  @click @on "#hello-world-6": {

    var data = { name:"", password:"" };  
    
    function onClose(root,btn)
    {
      if(btn == #cancel)
        return true;
      data = root.$(form).value; // gather fields from the form
      if( !data.password || !data.name)
      {
        root.$(p#error).text = "Neither name nor password can be empty";
        return false; // reject closing
      }
      return true;
    }
    
    var result = view.msgbox { //type:#error, - no type
                               icon: "user-login-48.png",
                               title: "Login",
                               content:$(#msg-box-contnent).text, // see <script type=...> above
                               onClose: onClose,
                               buttons:[{id:#login,text:"Login"},{id:#cancel,text:"Not now"}]
                             };

    if( result == #login )
      stdout.printf("Got login request: %V\n",data);
  }


</script>

  </head>
<body>

  <h1>view.msgbox() variations</h1>

  <button #hello-world-1>Simple</button>
  <button #hello-world-2>Simple with title</button>
  <button #hello-world-3>Msgbox with events</button>
  <button #hello-world-4>Msgbox with custom buttons</button>
  <button #hello-world-5>Msgbox with initialization</button>
  <button #hello-world-6>Msgbox with custom icon and inputs</button>
  <img src="sres:busy.png">

  <!-- custom layout for message box -->  
  <script type="text/html" #msg-box-contnent>
    <style>
      form { flow:row(label,input); border-spacing:10dip; }
      form > * { vertical-align:baseline; }
      form > label { horizontal-align:right; }
    </style>
    <p>Please provide login credentials <img src="sres:busy.png">:</p>
    <form>
      <label>Name:</label><input name="name" type="text" />
      <label>Password:</label><input name="password" type="password" />
    </form>
    <p #error style="color:red; height:1.4em;"></p>
  </script>
    
</body>
</html>

 

view.msgbox 主要消息弹窗依靠这个函数

//自定义弹窗

var g_dialog = view.window
        {
            url: self.url("window.html"),
            x:750,
            y:500,
            parameters:
            { // view.parameters inside new window
                Head: iMajor ,
                subitem: iMinor ,
                iWindows: iWindows ,
                Page:PageNumber,
                TotalFileSize:totalFileSize,
                onProc: OnProcCallBack,
                onClose: onCloseCallback,
                Language:self.language
            }
        }


  @click @on "#show-dialog-3":
    {
      var params = { one: "one", two: "two" }; // parameters to pass
      var v = view.dialog {
         url: self.url("samples/sample-dialog-2.htm"),
         x:300,  
         y:300,
         alignment:5, // with window center at 300,300
         parameters: params
      };
      stdout.printf("sample-dialog-2 result:%v\n",v);
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值