在我使用 Wordpress 的网站中,我有一个选项卡插件(WP-UI 选项卡、手风琴、滑块),并且由于在两个选项卡中我有 Google 地图嵌入代码,我需要使用 Javascript 函数(不是 jQuery,因为我的插件不允许它)强制调整第二张地图的大小,以便地图的中心不会转到左上角。
那么,是否有 JavaScript 来验证我是否在特定选项卡中调用调整大小图?
<script type="text/javascript">
google.maps.event.trigger(map, "resize");
});
</script>
我需要if
在触发器之前,但我不知道该放什么。
这是选项卡代码:
[wptabs type="accordion" mode="horizontal"]
[wptabtitle] Map 1[/wptabtitle] [wptabcontent]
这是嵌入的谷歌地图代码:
[/wptabcontent]
[wptabtitle] Map 2[/wptabtitle] [wptabcontent]
这是嵌入的 Google 地图 2 代码。
[cf]js[/cf] //this is to call the js function
[/wptabcontent]
[/wptabs]
更新代码:
Firefox 向我展示了这个:
<div id="wp-accordion-1" class="wp-accordion wpui-light wpui-styles"></p>
<p><h3 class="wp-tab-title"> Place A</h3> <div class="wp-tab-content"><div class="wp-tab-content-wrapper"></p>
<p>Coordenadas GPS:<br />
Latitude: Norte<br />
Longitude: Oeste</p>
<p> </p>
<p><iframe src="http://maps.google.pt/maps?f=q&source=s_q&hl=pt-BR&geocode=&q=42.654471,-2.914153&aq=&sll=41.236676,-8.332331&sspn=0.593802,1.234589&ie=UTF8&ll=40.654471,-7.914153&spn=0.018721,0.038581&t=m&z=14&output=embed" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" width="100%" height="auto"></iframe><br />
<small><a style="color: #0000ff; text-align: left;" href="http://maps.google.pt/maps?f=q&source=embed&hl=pt-BR&geocode=&q=40.654471,-7.914153&aq=&sll=41.236676,-8.332331&sspn=0.593802,1.234589&ie=UTF8&ll=40.654471,-7.914153&spn=0.018721,0.038581&t=m&z=14" target="_blank">Large Map</a></small></p>
<p></div></div><!-- end div.wp-tab-content --></p>
<p><h3 class="wp-tab-title"> Place B</h3> <div class="wp-tab-content"><div class="wp-tab-content-wrapper"></p>
<p> </p>
<p> </p>
<p><script type="text/javascript">
document.write("yoooo!");
google.maps.event.trigger(map, "resize");
document.write("yoooo!");
});
</script></p>
<p>Coordenadas GPS:<br />
Latitude: Norte<br />
Longitude: Oeste</p>
<p> </p>
<p><iframe src="http://maps.google.pt/maps?f=q&source=s_q&hl=pt-BR&geocode=&q=35.541329,-7.730044&aq=&sll=40.654483,-7.914145&sspn=0.00936,0.01929&g=40.654483,-7.914145&ie=UTF8&ll=40.741339,-7.730044&spn=0.018696,0.038581&t=m&z=14&output=embed" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" width="100%" height="auto"></iframe><br />
<small><a style="color: #0000ff; text-align: left;" href="http://maps.google.pt/maps?f=q&source=embed&hl=pt-BR&geocode=&q=40.741339,-7.730044&aq=&sll=40.654483,-7.914145&sspn=0.00936,0.01929&g=40.654483,-7.914145&ie=UTF8&ll=40.741339,-7.730044&spn=0.018696,0.038581&t=m&z=14" target="_blank">Large Map</a></small><br />
</div></div><!-- end div.wp-tab-content --></p>
<p></div><!-- end div.wp-tabs -->