SDK里传统方式都是提前定义好object,例如:
<body>
<button onclick="fullScreen()"> FullScreen</button>
<button onclick="captureScreen()"> CaptureScreen</button>
<select id="eWeather" onchange="changeWeather()">
<option>晴天</option>
<option>小雨</option>
<option>中雨</option>
<option>大雨</option>
<option>小雪</option>
<option>中雪</option>
<option>大雪</option>
</select>
<button onclick="play()"> Play</button>
<button onclick="pause()"> Pause</button>
<button onclick="stop()"> Stop</button>
<br />
<object id="renderControl" type="application/x-cm-3d8" style="height: 600px; width: 800px">
</object>
</body>
这里记录下在js代码里appendChild方式进行加载:
<body>
<div id="3d"></div>
</body>
<script type="text/javascript">
function init(){
var ocxDocument = document.getElementById("3d");
var ocxObject = document.createElement('object');
ocxObject.style.width="800px";
ocxObject.style.height="600px";
ocxObject.id="renderControl";
ocxObject.type="application/x-cm-3d8";
ocxDocument.appendChild(ocxObject);
}
</script>
能达到跟上面一样的效果。
参考:https://www.cnblogs.com/GuominQiu/archive/2013/08/17/3263748.html