【问题标题】:Jquery loads only after F5 in IEJquery 仅在 IE 中按 F5 后加载
【发布时间】:2012-09-20 06:59:35
【问题描述】:

我正在使用 Jcrop jQuery 在 MVC3 应用程序中裁剪图像。

以下是我的 JavaScript 函数:

    jQuery(function ($) {
    $('#imgLab').Jcrop(
        {
            onChange: showCoords,
            onSelect: coordsSelected,
            onRelease: clearCoords
        }
        );
});

图像 ID 为“imgLab”。

<img id="imgLab" src="@ViewBag.ObjLabTypeMaster.TopologyImagePath" alt="Lab" width="500" height="450" />

图片源路径来自数据库。

现在这在 FF、Safari 和 Chrome 中运行良好。 在 IE 中,它仅在我按 F5 后才有效。 谁能告诉我代码有什么问题?

【问题讨论】:

    标签: jquery asp.net-mvc jquery-plugins


    【解决方案1】:

    您可以尝试在脚本标签中添加“延迟”:

    <script defer>
        // Your code
    </script>
    

    或者,您可以尝试等到 DOM 准备好:

    $(document).ready(function(){
    
        $('#imgLab').Jcrop({
            onChange: showCoords,
            onSelect: coordsSelected,
            onRelease: clearCoords
        });
    
    });
    

    【讨论】:

      【解决方案2】:

      必须为 IE 设置 AllowSelect:true

      jQuery(function ($) {
      
              $('#imgLab').Jcrop(
              {
                  allowSelect: true,
                  //onChange: showCoords,
                  //                onSelect: coordsSelected,
                  onRelease: clearCoords,
                  onDblClick: opendetails
              }, function () {
                  Jcrop_Api = this;
              });
      });
      

      【讨论】:

        【解决方案3】:

        我不知道,但你可以试试这个,如果效果不好,你为什么不忽略 IE 并说页面在 IE 中不可用或所有功能都不可用,或者你可以自动如果此人正在使用 IE,则自动重新加载页面

        <script>
                $(document).ready(function() {
                    $('#imgLab').Jcrop(function() {
                        onChange: showCoords,
                        onSelect: coordsSelected,
                        onRelease: clearCoords
                    });
                });
        </script>
        

        要自动重新加载页面,请使用以下代码,

        <meta http-equiv="refresh" content="30" />
        <!-- content being the secounds before reload -->
        

        我相信您可以使用一些 PHP 代码添加或不添加它。

        【讨论】:

        • 它正在工作,但它会在每 30 秒后重新加载页面。我不想要。
        • 好吧,如果您使用我发送给您的第一个代码,则您不应该需要第二个代码,尽管如果我的第一个代码不起作用,您可以尝试使用第二个代码,尽管您可能会有将“内容”值更改为“1”或“0”。但就像我说的,如果它使用第一个代码,你不需要第二个
        猜你喜欢
        • 2015-04-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-08-03
        • 1970-01-01
        • 1970-01-01
        • 2012-04-25
        • 1970-01-01
        相关资源
        最近更新 更多