【发布时间】:2015-07-11 11:26:24
【问题描述】:
我是网络开发的新手。
如果我使用地址“www.xxxxxx.com/test.html#chgd”,则第二个手风琴应该正在展开。它适用于 Chrome,但不适用于 Firefox 和 Explorer。
适用于 Chrome 但不适用于 Firefox 和 Explorer 的源代码有什么问题?
我有一个相似的目的 (Expand Specific Accordion from URL),但它是完全不同的问题陈述。
我也使用过'window.location.hash;'但不幸的是,同样的问题发生了。
<script src="C:\Users\h\Desktop\test\jquery-1.11.2.min.js"></script>
<script src="C:\Users\h\Desktop\test\bootstrap.min.js"></script>
<script>
jQuery(document).ready(function() {
var url = document.location.toString();
if (url.match('#')) {
var hash = url.split('#')[1];
// collapse the expanded panel
$('#accordion .accordion-collapse').removeClass('in');
// expand the requested panel
$('#' + hash + '_c').addClass('in');
}
});
</script>
</head>
<body>
<div id="accordion" class="accordion-group">
<div class="panel">
<h4 id="cs" class="accordion-title"><a data-toggle="collapse" data-parent="#accordion" data-target="#cs_c">Child Survival: Boosting Immunity and Managing Diarrhoea</a></h4>
<div id="cs_c" class="accordion-collapse collapse in">
<p>...</p>
</div>
<h4 id="chgd" class="accordion-title"><a data-toggle="collapse" data-parent="#accordion" data-target="#chgd_c">Child Health, Growth and Development: Preventing Mental Impairment with Iodine and Iron</a></h4>
<div id="chgd_c" class="accordion-collapse collapse">
<p>...</p>
</div>
<h4 id="wmnh" class="accordion-title"><a data-toggle="collapse" data-parent="#accordion" data-target="#wmnh_c">Women’s and Newborn Survival and Health: Iron Supplementation and Food Fortification</a></h4>
<div id="wmnh_c" class="accordion-collapse collapse">
<p>...</p>
</div>
</div>
</div>
</body>
</html>
【问题讨论】:
-
Expand Specific Accordion from URL 的可能重复项 -> 内容相同,问题略有不同...
-
在 IE 中,你检查过什么控制台会告诉你吗?按F12。控制台。
-
尝试
window.location.hash获取哈希值。 -
Tim - 我想说的是相同的目的,但不是相同的问题或问题陈述。
-
你的 css & js 文件是本地化的吗?并且网站在网络服务器上?
标签: jquery twitter-bootstrap google-chrome internet-explorer firefox