11.8 移动文档中的对象

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <script>
        function slide() {
            var adBox = "testDiv";
            if (nextPos(adBox) <= (document.body.clientWidth - 150)) {
                document.getElementById(adBox).style.left = nextPos(adBox) + "px";
                setTimeout(slide, 100);
            }
            function nextPos(elem) {
                return document.getElementById(elem).offsetLeft + 100;
            }
        }
        function change() {
            var testDiv = document.getElementById("testDiv");
            if (testDiv.style.display == "block") {
                document.getElementById("testDiv").style.display = "none";
            } else  {
                document.getElementById("testDiv").style.display = "block";
            }
        }
    </script>
    <style>
        #testDiv {
            position: absolute;
            z-index: 2;
            display: none;
            width: 100px;
            background-color: #F00;
        }
    </style>
</head>
<body>
<div id="testDiv" onmouseover="slide()">
    testDiv;
</div>
<p>微信jsapi是网页javascript的接口,该接口允许厂商的网页对局域网设备(设备必须支持AirKiss3.0)和蓝牙设备进行操作。例如扫描设备,连接设备,收发数据,绑定设备等。
    微信硬件JSAPI接口属于微信JS-SDK的一部分,所以硬件JSAPI的使用首先需要遵循微信JS-SDK的使用规范。微信JS-SDK的使用方法请参考公众平台微信JS-SDK说明文档。
    微信硬件JSAPI使用:
    微信JS-SDK是使用JSAPI的基础,必须了解新框架的基本用法,如wx.config函数和wx.ready函数,这是所有JSAPI使用的前提
    在JS-SDK初始化的基础上,请按如下方法使用微信硬件JSAPI:
    a. 需要在wx.config的方法的参数jsApiList数组中,传入需要额外使用的jsapi名称。(在使用任何jsapi的接口前,必须先调用wx.config方法)。
    b. 需要在config方法中传入一个beta字段,值为true,则会在注入wx.invoke方法来调用还未开放的jsapi方法。(页面加载时就调用jsapi,则必须放到wx.ready回调中)。</p>
<button onclick="change()">click</button>
</body>
</html>