简体   繁体   English

图像未跨度显示

[英]Image not displaying in span

Here is my span in html 这是我的HTML跨度

 <span id="spProgress" runat="server"></span>

Now i have 2 javascript functions, one to display a loading indicator 现在我有2个javascript函数,其中一个显示加载指示器

  function DisablePage()
{
     document.getElementById('<%= spProgress.ClientID %>').innerHTML="<img src='Images/updateProgress.gif' />";
} 

Another function to hide it. 隐藏它的另一个功能。

function EnablePage()
{
    document.getElementById('<%= spProgress.ClientID %>').innerHTML='';
}

When i click a button it works perfectly fine on local system.But when i put it on production server the image is not displayed.I have checked the image url but its perfectly fine. 当我单击一个按钮时,它在本地系统上可以正常工作,但是当我将其放在生产服务器上时,图像不显示。 The surprising thing is that when i click on the button it does'nt display but if i download a file from my web application, then after that the image starts displaying properly. 令人惊讶的是,当我单击按钮时它不会显示,但是如果我从Web应用程序下载文件,则此后图像将开始正确显示。

Here is my client script code for download 这是我的客户端脚本代码可供下载

function hidePage()
{
    eraseCookie("DStatus");
    EnableMe();
}
function EnableMe()
{      
    var hddCdrDownloadRecordsLimit='<%=this.hddCdrDownloadRecordsLimit.ClientID %>';
    var hddTotalCount='<%=this.hddTotalCount.ClientID %>';

  if((document.getElementById(hddCdrDownloadRecordsLimit).value) < (document.getElementById(hddTotalCount).value))
    {
        DisablePage();
        document.getElementById('<%=this.btnSearch.ClientID %>').disabled=true;
    } 
    else 
    {
       DisablePage();
    } 
var downLoadStatus = readCookie("DStatus");
if (downLoadStatus == "Completed")
{
    EnablePage();
    document.getElementById('<%=this.btnSearch.ClientID %>').disabled=false;
}
else
{
 setTimeout("EnableMe()", 6000);
}

} }

You should try to load image at page load, putting your image tag inside span and just work with "show" or "hide" that element. 您应该尝试在页面加载时加载图像,将图像标签放在span内,然后仅使用“显示”或“隐藏”该元素。

<span id="spProgress" runat="server" style="display:none;"><img src='Images/updateProgress.gif' /></span>

Create a function that changes the style of span element to show (display:block) or hide (display:none). 创建一个将span元素的样式更改为显示(display:block)或隐藏(display:none)的函数。

Hope that help. 希望对您有所帮助。

have you check that the html is being appended into the span? 您检查过html是否被追加到跨度中吗? I would use CHrome or firebug to inspect the element and then click on the open url in new tab to see the full url it is using for the image. 我将使用CHrome或firebug来检查元素,然后单击“新”选项卡中的打开URL,以查看其用于图像的完整URL。 It could be that it has the wrong directory online and you need to but ./Images first etc 可能是在线目录错误,您需要先./Images等

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM