<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <title>ThingJS的 Iframe演示</title> </head> <body> <div width="800px"> <button style="position: absolute;top: 15px;left: 15px;width: 75px;" onclick="flyToCar()">飞到小车</button> <button style="position: absolute;top: 45px;left: 15px;width: 75px;" onclick="flyToBack()">返 回</button> <iframe id="testMsg" style="width: 600px;height: 400px;" src='https://www.thingjs.com/s/aa25e09eae2f73e6ce080d73?params=105b0f77fd24654d4eebc434e9'></iframe> </div> <script> function flyToCar() { var a = document.getElementById("testMsg"); var msg = { funcName: 'test' } a.contentWindow.postMessage(msg, "*"); } function flyToBack() { var a = document.getElementById("testMsg"); var msg = { funcName: 'test2', param: "2" } a.contentWindow.postMessage(msg, "*"); } </script> </body> </html>