在 asp.net MVC 中加载 Gif 的正确方法

发布于 2025-01-03 14:01:28 字数 1500 浏览 2 评论 0原文

我正在尝试找到一种正确加载 gif 的方法...显然我现在的做法会导致页面上出现混合内容警告。我尝试过使用 Url.Content(~/path/to/javascript/file) 和 ResolveClient(~/doesn't/work/either)...我能做些什么来规避此警告?我将向您展示我的代码+我收到的警告...

function DemoSearchInternals()
{
    //debugger;
    var form = $("#DemoGraphID");
    $div = $("#TabView1");
    var srlzdform = form.serialize();
    var PopID = <% =PopID %>;
    var options = [];
    var $url = $("#target").attr("action");
    //getSize();
    $('<div id="overlay">').css({
        position: 'absolute',
        opacity: 0.2,
        top : $div.offset().top,
        left : $div.offset().left,
        width : $div.width(),
        height : $div.outerHeight(),
        background: 'grey url(<%=ResolveClientUrl("~/images/indicator_web20_working.gif")%>) no-repeat center'
    }).hide().appendTo($div);//Url.Content("~/images/indicator_web20_working.gif")
    $("#overlay").fadeIn();
    $.post('<%:Url.Action("SearchByDemographic", "PatientACO")%>', srlzdform, function (data)
    {
        DisplayDemographicSearch(data);
        $("#overlay").fadeOut('slow', function () {
             $("#overlay").remove();
        });
    });        
}

我收到的警告

我特别关心背景部分?在 asp.net MVC2 应用程序中,这是调用 url 的最佳方式吗?本节:

background: 'grey url(<%=Url.Content("~/images/indicator_web20_working.gif")%>) no-repeat center'

您看到哪里写着灰色 url(yadda yadd) 我正确调用了 Url 吗?有更好的调用方式吗?

I am trying to find a way to correctly load a gif... Apparently the way I am doing it now is causing a mixed content warning on the page. I have tried using Url.Content(~/path/to/javascript/file) and ResolveClient(~/doesn't/work/either)... What can I do to circumvent this warning? I will show you my code + the warning I get...

function DemoSearchInternals()
{
    //debugger;
    var form = $("#DemoGraphID");
    $div = $("#TabView1");
    var srlzdform = form.serialize();
    var PopID = <% =PopID %>;
    var options = [];
    var $url = $("#target").attr("action");
    //getSize();
    $('<div id="overlay">').css({
        position: 'absolute',
        opacity: 0.2,
        top : $div.offset().top,
        left : $div.offset().left,
        width : $div.width(),
        height : $div.outerHeight(),
        background: 'grey url(<%=ResolveClientUrl("~/images/indicator_web20_working.gif")%>) no-repeat center'
    }).hide().appendTo($div);//Url.Content("~/images/indicator_web20_working.gif")
    $("#overlay").fadeIn();
    $.post('<%:Url.Action("SearchByDemographic", "PatientACO")%>', srlzdform, function (data)
    {
        DisplayDemographicSearch(data);
        $("#overlay").fadeOut('slow', function () {
             $("#overlay").remove();
        });
    });        
}

The warning that I get

I am particularly concerned about the background section? In an asp.net MVC2 app, is that the best way to call url? This section:

background: 'grey url(<%=Url.Content("~/images/indicator_web20_working.gif")%>) no-repeat center'

You see where it says grey url(yadda yadd) am I calling Url correctly? Is there a better way to call it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文