Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript IE7 Ajax加载图像问题-css属性显示不工作_Javascript_Html_Ajax_Firefox_Internet Explorer 7 - Fatal编程技术网

Javascript IE7 Ajax加载图像问题-css属性显示不工作

Javascript IE7 Ajax加载图像问题-css属性显示不工作,javascript,html,ajax,firefox,internet-explorer-7,Javascript,Html,Ajax,Firefox,Internet Explorer 7,我试图有条件地显示一个图像,但它不仅仅在IE浏览器中工作。在Firefox中,它工作正常。还有其他方法可以达到同样的效果吗?谢谢 <span id="goog" style="display:none;" > <img height="14" width="14" src="static/images/ajax_load.gif" /> </span> if(document.getElementById("goog")){ alert('g

我试图有条件地显示一个图像,但它不仅仅在IE浏览器中工作。在Firefox中,它工作正常。还有其他方法可以达到同样的效果吗?谢谢

<span id="goog" style="display:none;" >
    <img height="14" width="14" src="static/images/ajax_load.gif" />
</span>

if(document.getElementById("goog")){
    alert('goog');
    document.getElementById("goog").style.display="none";
}

if(document.getElementById("goog")){
    alert('goog');
    document.getElementById("goog").style.display="inline";
}

if(document.getElementById(“goog”)){
警惕(“咕咕”);
document.getElementById(“goog”).style.display=“无”;
}
if(document.getElementById(“goog”)){
警惕(“咕咕”);
document.getElementById(“goog”).style.display=“inline”;
}
更新:03/07

我一直在努力为IE解决这个问题,但我还不能做到

问题:我正在使用自定义javascript树组件从和填充树中单击的每个节点的数据或子节点,我正在使用Ajax。每次,如果正在处理某些内容,我都希望显示ajax图像(gif)和“处理”文本。我在Firefox中尝试的所有功能都可以正常工作,但在IE中无法正常工作。每个节点在HTML文档中都是一个div标记,如下所示:

<div class="dTreeNode">
<a href="javascript: d.o(1);">
    <img id="jd1" alt="" src="static/images/minusbottom.gif"/>
</a>
0
<input id="ch1" type="checkbox" onclick="javascript: changeCheckBoxValues(1);"/>
<a id="linkNode1" class="node" onclick="javascript: d.o(1); return false" href="#">AIG</a>
<span id="aj1" style="display: none;">
    <img height="14" width="14" src="static/images/ajax_load.gif"/>
</span>

0

当Ajax请求被激发时,将显示一个静态的、以前未显示的(display:none),如下所示

<table  align="center"  width="80%" border="1" cellspacing="0" cellpadding="0" id="proc"
        style="display:none;border-collapse: collapse; border: 1px solid; border-color: #D8D8D8;">
        <tr>
            <td width="33%"></td>
            <td class="buttonBar" width="33%">
                <span class="TextBlackNormal">&nbsp;&nbsp;&nbsp;&nbsp;processing </span>
            </td>
            <td width="33%"></td>
        </tr>
</table>

处理
这两个锚定标记都会触发Ajax请求,但是(GIF图像和处理文本的)显示并不仅仅在IE中工作

我试过以下方法:

1) 交换了DIV中锚定标记的href&onclick值 2) 尝试DOM的可见性值,而不是显示 3) 创建动态DOM元素并添加图像+文本 4) 显示ajax加载图像+处理文本的容器(div/table)的innerHTML

我发现问题的根源不是Ajax调用,至少我认为是这样

当我进行实验时,在IE中使用display/visibility对图像+文本进行有条件显示,并使用一些DOM值(文本框的值),效果非常好

我真的不确定是什么导致了这个问题


感谢您的帮助。

文档。IE中的getElementById实际上可以返回带有
name=“goog”
的元素。另外,如果页面上有多个元素具有这样的id,则这是不正确的,在这种情况下,不同的浏览器可能会有不同的行为。在IE中执行类似的检查:

alert(document.getElementById("goog").id);
alert(document.getElementById("goog").tagName);
您可以尝试“内联”更改“”
或者访问

我认为这个问题有点难以理解。但这里最大的问题是你使用的是什么IE版本。旧版本的IE在隐藏/显示元素时存在一些渲染问题。要更正此错误,请使用
位置:相对
缩放:1

但是脚本应该可以工作,但是在AJAX调用中可能会出现错误,这会阻止您调用success函数。尝试添加一个错误事件,并查看是否触发该事件。我不太确定你从服务器收到了什么,但是IE有时会在被阻止的元素上失败


但是在JSFIDLE中展示会很好。

从下面引用的文本中

问题:我正在使用dtree中定制的javascript树组件,为了填充树中单击的每个节点的数据或子节点,我正在使用Ajax。每次,如果正在处理某些内容,我都希望显示ajax图像(gif)和“处理”文本。我在Firefox中尝试的所有功能都可以正常工作,但在IE中无法正常工作。每个节点在HTML文档中都是一个div标记,如下所示:

<div class="dTreeNode">
<a href="javascript: d.o(1);">
    <img id="jd1" alt="" src="static/images/minusbottom.gif"/>
</a>
0
<input id="ch1" type="checkbox" onclick="javascript: changeCheckBoxValues(1);"/>
<a id="linkNode1" class="node" onclick="javascript: d.o(1); return false" href="#">AIG</a>
<span id="aj1" style="display: none;">
    <img height="14" width="14" src="static/images/ajax_load.gif"/>
</span>
我认为在ajax调用获取原始数据之前,您需要显示处理文本

如果是这样的话,您可以通过检查ajax状态来使用图像显示

在要显示处理文本的每一行(可能在水平方向上靠近定位文本)中都有一个div

在ajax回调函数上

xmlhttp.onreadystatechange=function()
{
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
  {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
  }
  else
  {
     document.getElementById("goog").innerHTML ='<img src=static/images/ajax_load.gif>';
  }
}
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4&&xmlhttp.status==200)
{
document.getElementById(“txtHint”).innerHTML=xmlhttp.responseText;
}
其他的
{
document.getElementById(“goog”).innerHTML='';
}
}

我想这对你来说够了吧?如果我误解了你的问题,我很抱歉。

谢谢-从来没有这样想过,我会试试的。不过我不是很有希望。那么
position:relative
在元素上显示
display:none
可能有效。