0

我想找出为什么在页面加载时某些元素会隐藏在页面加载 IE 中,有时它们不会(在 IE9 中测试)。我正在尝试重新创建 jqueryui 手风琴行为,因为它做了同样的事情/有同样的问题。

在 php 中使用 header() 或什至使用标准链接重新加载或单击重定向/重新加载 ling 时,在某些情况下 hide() 不起作用,其他时候相同的链接有效并且元素隐藏。

IE 显示在 IE9 标准下工作,因为我发现 jQ/jQui 不正式支持怪癖,以确保我什至在文档头中有 X-UA-Compatible" content="IE=edge" 甚至发送相应的标题使用 php。

W3C 验证器文档中,验证 /xhtml1 过渡/

相关的 html 标记是 /simplified/

<h3><a id="tog1" href="/....">...</a></h3>
<div class="smg" id="tog1e"> .... </div>

<h3><a id="tog2" href="/....">...</a></h3>
<div class="smg" id="tog2e"> .... </div>

<h3><a id="tog3" href="/....">...</a></h3>
<div class="smg" id="tog3e"> .... </div>

在外部 js 文件中我有这个

jQuery(function() { 
// selectors are "a" (links)
$("#tog1").click( function(e){ 
 $("div.smg").hide(); $("#tog1e").show();e.preventDefault();});
$("#tog2").click( function(e){ 
 $("div.smg").hide(); $("#tog2e").show();e.preventDefault();});
$("#tog3").click( function(e){ 
 $("div.smg").hide(); $("#tog3e").show();e.preventDefault();});

if(document.location.href.indexOf('...link of tog1...') > -1 ) 
{  $("div.smg").hide(); $("#tog1e").show();}
else if ( document.location.href.indexOf('...link of tog2...') > -1 ) 
{ $("div.smg").hide(); $("#tog2e").show();}
else { $("div.smg").hide(); $("#tog3e").show();}

//.... other unrelated code follows after

我仍然无法弄清楚为什么有时在 IE 中可以工作而有时不能。其他浏览器(当前的 Chrome 和 Firefox)总是可以正常工作。

添加

我刚刚提到它可能(或可能不)与页面上还使用其他框架(mootools)有关。然而,正如所说的 Firefox 和 Chrome 不会抱怨并且总是可以工作,而 IE 有时不会,但只是有时。

在 IE 中,我发现有时控制台会告诉我某些对象没有某些属性或功能(这可能与使用这两个框架有关)并且我已经开始使用 jQ 的 noconflict 以及将 '$' 替换为 'jQuery'在脚本中,但到目前为止它看起来没有帮助。

我该如何解决这个问题?我确实需要 MooTools 和 jQuery。

4

0 回答 0