我试图在点击时显示谷歌地图 java 脚本更改其显示属性并显示谷歌地图。它不能在 IE 8 上工作,如果我不使用 CSS,它在其他浏览器上也能正常工作,它在 IE 上也能正常工作
我的代码如下
<div class="getDirectionsBtnMain">
<a href="#" id="new-yorkiframeNav" onclick="toggle_visibility('new-yorkiframe');">
</a>
</div>
<div id="new-yorkiframe" style="background: none repeat scroll 0% 0% rgb(5, 72, 65); width: 950px; border: 10px solid rgb(5, 72, 65);" class="tab-pane vcard">
<iframe frameborder="0" style="width: 100%; height: 379px;" marginheight="0" marginwidth="0"
src="https://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=+40+Wall+Street,+11th+Floor+New+York,+NY+10005&aq=&sll=37.0625,-95.677068&sspn=39.320439,86.572266&t=m&ie=UTF8&hq=&hnear=40+Wall+St,+New+York,+10005&iwloc=A&output=embed">
</iframe>
</div>
脚本是这样的,
<script type="text/javascript">
function toggle_visibility(id) {
var e = document.getElementById(id);
alert(e.style.display);
if (e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
if (e.style.display != 'block' && e.style.display != 'none')
e.style.display = 'block';
}
</script>
在 CSS 中我使用了这个属性,
#new-yorkiframe{display:none;}
首先,它没有显示它的 Display 属性,它显示“null”,我在脚本中提醒它在其他浏览器中也表现相同,但在脚本中更改其属性后,它在除 IE 之外的其他浏览器中显示 map
但如果我将其 css 属性更改为,
new-yorkiframe{display:none;}
它的点击按钮在 ie 和其他浏览器上显示和隐藏 map 。
如果我想在第一次页面加载时隐藏 map ,我应该怎么做??
希望合作
提前致谢
最佳答案
您是否在关闭 html 标签之前保留了“<script>..you code..</script>
”
关于javascript - 单击 Css 显示属性更改时的脚本无法正常工作 Asp.net?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20515377/