js跨域访问(iframe)

ext太深高,结合googleMap真是蛋疼,下面是2个页面的跨域访问
你妹的调了一上午,结果有2个错误找了半天没找到
1.不能再render回调函数中调用getRemoteJs,此时html:还未实例化,无法找到<iframe>
2.Document.doamin中的Document要大写。。你妹的,这什么命名规则啊

var map;
var geocoder;
function getRemoteJS(){
alert("getRemoteJs~");
Document.domain="test1.com";
var remoteHtml;
remoteHtml=document.getElementById("googleMap").contentDocument.getElementById("address").value;
if(remoteHtml)
alert("address"+remoteHtml);
else
alert("false");
}

function findAddress(){
var address = text_search_city.getValue();
if(map)
alert(address);
else
alert("false");
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}

function showMap(){
document.domain='test1.com';
var remoteHtml;
remoteHtml=document.getElementById("googleMap").contentDocument;

geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
if(remoteHtml.getElementById("map_canvas"))
{map = new google.maps.Map(remoteHtml.getElementById("map_canvas"), myOptions);
alert("success");
}
else
alert("false");
}

var btn_search_city=new Ext.Button(
{
text : '查询',
iconCls : 'icon-search',
handler : getRemoteJS
});

var text_search_city=new Ext.form.TextField({
id:'testSearchCity',
name : 'textSearchCity',
width : 200,
emptyText : '多条件可用逗号或者空格隔开!',
listeners : {
'specialkey' : function(field, e) {
if (e.getKey() == Ext.EventObject.ENTER) {
getRemoteJS();
}
}
}
});

function test(){
alert("aaaa");
}

var googleMap_panel=new Ext.Panel({
title : 'googleMap',
iconCls : 'icon-plugin',
region : 'center',
border : 'layout',
frame : true,
layout:'fit',
height:'100%',
//defaults: {
// collapsible: true,
// split: true
//},
tbar:[text_search_city,btn_search_city],
listeners:{
//render:getRemoteJS
},
items:[{
title:'hellow',
height:'100%',
id:'mapPanel',
//html:'<div id="map_canvas" style="height:90%;background-color:red">cc</div>'
html:'<iframe id="googleMap" scrolling="no" border="0" width="970" height="700" src="http://www.test1.com:9001/bmsh/test2.html"> </iframe>',
listeners:{
//render:getRemoteJS
}

}]

});

var p_googleMap={
id:'googleMap-panel',
border : false,
layout : 'border',
items : [googleMap_panel]
};


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值