javascript - 单击 Css 显示属性更改时的脚本无法正常工作 Asp.net?

标签 javascript asp.net css internet-explorer google-maps

我试图在点击时显示谷歌地图 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/

相关文章:

asp.net - 请求重定向到/Account/Login?ReturnUrl=%2f,因为服务器上安装了 MVC 3

jquery - 如何在标题中获取仅图标的控制组?

javascript - fullCalendar:我在渲染 100 年之前的事件(0000 - 0099 年)时遇到问题(使用 ISO8601 格式)

javascript - 使用 Javascript 为 div 设置样式

asp.net - 尝试在 Godaddy 上使用托管融合重写器时出现 System.Web.AspNetHostingPermission SecurityException

c# - 是否可以在 web.config 中针对每个 Controller 设置用户授权? (不能使用AuthorizeAttribute)

html - Safari:即使有隐藏元素,阴影过滤器仍然可见

css - 如何将嵌入式 radio 控件放入React-Bootstrap?

javascript - Jquery 文件拖放给我一个 "insecure operation"错误

javascript - 如何更新对象内字符串中的 html 元素?