现在有两个页面A.html、B.jsp其中代码如下:
A.html <script type="text/javascript">
var xmlHttp = null;
function createXMLHttpRequest()
{
if(window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
try
{
xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("load xml error!");
}
}
}
}
function sendRequest()
{
if(xmlHttp == null)
{
createXMLHttpRequest();
} xmlHttp.open("GET","ShowLocationServlet",true); xmlHttp.onreadystatechange = HandleResponse; xmlHttp.send(null);
} function HandleResponse()
{
if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
{
var content = xmlHttp.responseText;
var coords = content.split(';');
alert(coords.length);
for(var i = 0; i < coords.length-1 ; i++)
{

                             var location = coords[i].split(',');

var x = location[1];
var y = location[2];
var locationName = location[3];
var description = location[4];

addflashMarker(x,y,locationName,i); }
}
}
</script>
  </head>  <body>
     <form>
   <table border="0" width="100%" height="100px">
      <tr>
   <td><center><input type="button" value="搜索" onclick="sendRequest()"/></center></td>
      </tr>
   </table>
     </form>
    <iframe src="B.jsp" width="85%" height="632px" align="right" id="mapView" name="mapView"></iframe>
  </body>
</html>--------------------------------------------------------------------------------------------------------------B.jsp<SCRIPT LANGUAGE='JavaScript'> var _mapObj;
function addFlashMarker(x,y,locationName,i)
{
  var latlng;
var er;
var oStyle = new GStyle()
oStyle.iconSrc = "image/icon1.swf";
oStyle.infoWinHtml = "<b>"+locationName+"</b>";
latlng= new GLatLng(x,y);
er = new GMarker(latlng,locationName,oStyle,"SWUGIS"+i);
er.editable=true;
_mapObj.addOverlay(er);
}
--------------------------------------------------------------------------------------------------------------
现在就是想把A.html页面中从后台取到的数据送到B.jsp执行addFlashMarker方法。求高手帮帮忙!

解决方案 »

  1.   

    document.getElementById('mapView').addflashMarker(x,y,locationName,i);
      

  2.   

    <input type="button" value="Click" onclick="document.getElementById('mapView').contentWindow.addFlashMarker()"/>
      

  3.   

    <input type="button" value="Click" onclick="document.getElementById('mapView').contentWindow.addFlashMarker(x,y,locationName,i)"/>
      

  4.   

    var mapView;
    if(document.frames){
     mapView= frames.document.frames('mapView');
    }else{
    mapView=document.getElementById('mapView').contentWindow;
    }
    mapView.addFlashMarker(x,y,locationName,i);