/** * Created by Administrator on 2017/12/25. */ function postToIframeMethed(methedName,data) { // if(typeof(exec_obj)=='undefined'){ // exec_obj = document.createElement('iframe'); // exec_obj.name = 'tmp_frame'; // exec_obj.src = 'http://139.196.105.31/HKGisShare/ZoomIn.html'; // exec_obj.style.display = 'none'; // document.body.appendChild(exec_obj); // }else{ // exec_obj.src = 'http://139.196.105.31/HKGisShare/ZoomIn.html?' + Math.random(); // } var win = document.getElementsByTagName('iframe')[0].contentWindow; // var obj = { name: 'Jack' }; // 存入对象 win.postMessage(JSON.stringify({method: methedName, data: data}), 'http://10.214.3.150:8080/HKGisShare/'); // 读取对象 // win.postMessage(JSON.stringify({key: 'storage', method: "get"}), "*"); window.onmessage = function(e) { if (e.origin != 'http://localhost') return; // "Jack" console.log(JSON.parse(e.data).name); }; } function ZoomIn() { postToIframeMethed("ZoomIn") } function ZoomOut() { postToIframeMethed("ZoomOut") } function Clear() { postToIframeMethed("Clear") } function ViewChange() { postToIframeMethed("ViewChange") } function fullExtent() { postToIframeMethed("fullExtent") } function measureSquare() { postToIframeMethed("measureSquare") } function measureLength() { postToIframeMethed("measureLength") } function downLoadPicture() { postToIframeMethed("downLoadPicture") } function doGetGraphicByJson(jsonStr) { postToIframeMethed("doGetGraphicByJson",jsonStr) } function drawSquare() { postToIframeMethed("drawSquare") } function query(Str,layerName) { postToIframeMethed("query",[Str,layerName]) } function doOpenFeatureLayer(layerId,layerVisible){ postToIframeMethed("openFeatureLayer",[layerId,layerVisible]) } function doOpenFeatureLayer1(layerVisible){ postToIframeMethed("openFeatureLayer1",[layerVisible]) } function doOpenFeatureLayer2(layerVisible){ postToIframeMethed("openFeatureLayer2",[layerVisible]) } function doOpenFeatureLayer3(layerVisible){ postToIframeMethed("openFeatureLayer3",[layerVisible]) }