1、内嵌web ,web内用api对象

1、

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>云API</title>
    <link rel="stylesheet" type="text/css" href="./css/api.css"/>
    <link rel="stylesheet" type="text/css" href="./css/style.css"/>
</head>
<body>
  <header>
  </header>
</body>
<script type="text/javascript" src="script/api.js"></script>
<script type="text/javascript">
    apiready = function () {
      var closeAPP = {
          count: 0,
          timer: null,
          time: 1500
      }
      api.addEventListener({
            name: ‘keyback‘
          }, function(ret, err) {
          closeAPP.count++;
          if(closeAPP.count >= 2){
              api.closeWidget({
                  id: ‘A6028342539653‘,
                  silent: true,
                  })
          }
          else{
                /*api.toast({
                    msg: ‘再按一次退出应用‘,
                    duration: closeAPP.time,
                    location: ‘bottom‘
                });*/
                browser.historyBack(
                    function(ret, err) {
                        if (!ret.status) {
                            //api.closeWin();
                            //直接退出,不用closeWin() 这种强硬的方式
                        }
                    }
                );
            }
            clearTimeout(closeAPP.timer);
            closeAPP.timer = setTimeout(function(){
                    closeAPP.count = 0;
            },closeAPP.time)
        });
        //双击退出APP
        $api.fixStatusBar( $api.dom(‘header‘) );
        api.setStatusBarStyle({
            style: ‘dark‘,
            color: ‘#6ab494‘
        });
        api.openWin({
            name: ‘page1‘,
            url: ‘http://suyijie.weiyouqq.com‘,
            pageParam: {
                name: ‘test‘
            }
        });
        /*
        <!DOCTYPE HTML>
        <html>
        <head>
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <title></title>
        </head>
        <body>
        <script>
            alert("我是正常的运行~!");
            apiready = function (){
                //alert("我是内部运行~!");
            }
        </script>
        </body>
        </html>
        */
    }
  </script>
</html>