<!doctype html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=640,user-scalable=no,target-densitydpi=device-dpi" user-scalable=no /> <title>API Test</title> </head> <body class=""> <div> <input type="text" class="openid" name="openid"/> <div class="mk-content"> <input type="button" id="openid" class="test" value="测试获取Openid" /> </div> </div> </body> </html> <script type="text/javascript"> function MCS_ClientNotify(EventData) { EventData = strToJson(EventData); switch(EventData['event']){ case 'OnUserChange':{ //EventData['userid']就是当前聊天的用户openid console.log(EventData['userid']); document.getElementById("openid").value=EventData['userid']; break; } case 'OnMapMsgClick':{ break; } } } function strToJson(str){ var json = (new Function("return " + str))(); return json; } </script>