<div class="codetitle"> <span><a style="CURSOR: pointer" data="85190" class="copybut" id="copybut85190" onclick="doCopy('code85190')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code85190"> <br> <br> <br> <br><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <br><title>无标题文档</title> <br> <br><input type="button" value="test" style="height:500px"> <br>选择经度:<input type="text" id="txtSelect"> <br><iframe name="map" src="baidumap.htm" id="map" style="display:none"></iframe> <br> <br> <br> <br><script type="text/javascript"> <BR>document.getElementById("txtSelect").onfocus=function(){ <BR>var windows = document.getElementById("window"); <BR>var title = document.getElementById("title"); <BR>var layer = document.getElementById("layer"); <BR>if(windows==null&&layer==null&&title==null){ <BR>var style = document.createElement("style"); <BR>style.type="text/css"; <BR>document.body.appendChild(style); <BR>var styleText = "#layer{ width:100%;height:100%;background:#000000;position:absolute;z-index:100;left:0;top:0;filter:alpha(opacity=40); opacity:0.4}"; <BR>styleText+="#window{position:absolute; z-index:1000;background:#ffc;}"; <BR>styleText+="#title{ background:#CCFFFF;width:100%;height:15%;font-size:2em;font-weight:bold; text-align:left; line-height:1.5em }" <BR>styleText+="#content{ height:85%;width:100%;background:#CCCCCC}"; <BR>styleText+="#frame{ width:100%;height:100%;} #map{ width:100%;height:100%}"; <BR>try{ <BR>if(typeof style.styleSheet.cssText!="undefined"){ <BR>style.styleSheet.cssText=styleText; <BR>} <BR>}catch(ex){ <BR>style.appendChild(document.createTextNode(styleText)); <BR>} <BR>var layer = document.createElement("div"); <BR>document.body.appendChild(layer); <BR>layer.id="layer"; <BR>var windows = document.createElement("div"); <BR>document.body.appendChild(windows); <BR>windows.id="window"; <BR>windows.style.height="400px"; <BR>windows.style.width = "600px"; <BR>var height = parseInt(windows.style.height); <BR>var width = parseInt(windows.style.width); <BR>windows.style.top = parseInt(document.documentElement.clientHeight/2-height/2)+"px"; <BR>windows.style.left = parseInt(document.documentElement.clientWidth/2-width/2)+"px"; <BR>var title = document.createElement("div"); <BR>windows.appendChild(title); <BR>title.id="title"; <BR>title.appendChild(document.createTextNode("点此关闭")); <BR>var content = document.createElement("div"); <BR>windows.appendChild(content); <BR>content.id="content"; <BR>var map = document.getElementById("map"); <BR>content.appendChild(map); <BR>map.style.display="block"; <BR>if(typeof layer.style.opacity!="undefined"){ <BR>layer.style.opacity=0.5; <BR>} <BR>else if(typeof layer.style.filter!="undefined"){ <BR>layer.style.filter="alpha(opacity=50)"; <BR>} <BR>} <BR>else{ <BR>if(typeof layer.style.opacity!="undefined"){ <BR>layer.style.opacity=0.5; <BR>} <BR>else if(typeof layer.style.filter!="undefined"){ <BR>layer.style.filter="alpha(opacity=50)"; <BR>} <BR>layer.style.zIndex=100; <BR>windows.style.zIndex=1000; <BR>layer.style.display="block"; <BR>windows.style.display="block"; <BR>} <BR>layer.onclick = title.onclick = function(){ <BR>windows.style.zIndex=-1000; <BR>windows.style.display="none"; <BR>//让层渐隐 <BR>var timer = setTimeout(displayLayer,200); <BR>function displayLayer(){ <BR>if(typeof layer.style.opacity!="undefined"){ <BR>var layers = document.getElementById("layer"); <BR>var opacity = parseFloat(layers.style.opacity); <BR>opacity = opacity-0.1; <BR>if(opacity>0){ <BR>setTimeout(arguments.callee,100); <BR>} <BR>else if(opacity<0){ <BR>layers.style.zIndex=-100; <BR>clearTimeout(timer); <BR>} <BR>layers.style.opacity = opacity; <BR>} <BR>else if(typeof layer.style.filter!="undefined"){ <BR>var layers = document.getElementById("layer"); <BR>var filterStyle = layers.style.filter; <BR>//opacity = parseInt(filterStyle.substring(filterStyle.indexOf("=")+1)); <BR>var opacity = parseInt(filterStyle.match(/\d+/)); <BR>opacity = opacity-10; <BR>if(opacity>0){ <BR>setTimeout(arguments.callee,100); <BR>} <BR>else if(opacity<0){ <BR>layers.style.zIndex=-100; <BR>clearTimeout(timer); <BR>} <BR>layers.style.filter = "alpha(opacity="+opacity+")"; <BR>} <BR>else{ <BR>throw new Error("your browser version lower!"); <BR>} <BR>} <BR>document.getElementById("txtSelect").value=frames["map"].document.getElementById("hidden").value; <BR>} <BR>} <BR>window.onunload=function(){ <BR>var windows = document.getElementById("window"); <BR>var title = document.getElementById("title"); <BR>var layer = document.getElementById("layer"); <BR>layer.onclick = windows.onclick=null; //清除事件绑定 <BR>document.body.removeChild(layer); <BR>windows.removeChild(title); <BR>document.body.removeChild(windows); <BR>} <BR></script> <br> </div> <br>这是那个框架的页面,显示百度地图的坐标 <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="76905" class="copybut" id="copybut76905" onclick="doCopy('code76905')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code76905"> <br> <br> <br><meta http-equiv="Content-Type" content="text ml; charset=utf-8"> <br><title>百度地图</title> <br><script type="text/javascript" src="http://api.map.baidu.com/api?key=458d39374361da27e548367a735831ba&v=1.0&services=true"></script> <br><link href="/Theme/Default/Admin/reset.css" rel="stylesheet" type="text/css"> <br><link href="/Theme/Default/Admin/style.css" rel="stylesheet" type="text/css"> <br> <br> <br><div> <br><form> <br><div style="position: absolute; width: 730px; height: 590px; top: 35; left: 0; border: 1px solid gray; overflow-y: hidden;" id="container"> <br> </div> <br><input id="text_" class="textbox200" style="width: 150px" type="text" value="成都"> <br><input class="button90" type="button" value="查询" onclick="searchByStationName(document.getElementById('text_').value);"> <br><input type="hidden" id="hidden" value="104.105, 30.624"> <br> </form> <br> </div> <br> <br><script type="text/javascript"> <BR>var map = new BMap.Map("container"); <BR>map.centerAndZoom(new BMap.Point(104.105, 30.624), 6); <BR>map.addControl(new BMap.NavigationControl()); //导航 <BR>map.addControl(new BMap.ScaleControl()); <BR>map.addControl(new BMap.OverviewMapControl()); <BR>map.addEventListener("click", function (e) { <BR>document.getElementById("hidden").value = e.point.lng+","+e.point.lat; <BR>}); <BR>var localSearch = new BMap.LocalSearch(map, { <BR>renderOptions: { <BR>pageCapacity: 8, <BR>autoViewport: true, <BR>selectFirstResult: false <BR>} <BR>}); <BR>localSearch.enableAutoViewport(); <BR>function searchByStationName(name) { <BR>var keyword = name; <BR>localSearch.setSearchCompleteCallback(function (searchResult) { <BR>var poi = searchResult.getPoi(0); <BR>alert(poi.point.lng + " " + poi.point.lat); <BR>document.getElementById("hidden").value = e.point.lng+","+e.point.lat; <BR>map.centerAndZoom(poi.point, 8); <BR>}); <BR>localSearch.search(keyword); <BR>} <BR></script> <br> <br> </div>