我是网络开发的新手。
如果我使用地址" www.xxxxxx.com/test.html#chgd" ;,第二支手风琴应该扩展。它适用于Chrome,但不适用于Firefox和资源管理器。
适用于Chrome但不适用于Firefox和资源管理器的源代码有什么问题?
我有一个类似的目的(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>
答案 0 :(得分:0)
确保源代码
<script src="js/jquery-1.11.2.min.js"></script> and not <script src="C:\Users\h\Desktop\test\jquery-1.11.2.min.js"></script> in relation to Firefox.
在IE中,请确保您已取消激活activecontrol,一切都会正常。