简体   繁体   中英

Jquery loads only after F5 in IE

I am using Jcrop jQuery to crop an image in an MVC3 application.

The following is my JavaScript function:

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

Image ID is 'imgLab'.

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

Image src path is coming from database.

Now this works fine in FF, Safari and Chrome. In IE it only works after I press F5. Can anyone tell me what is wrong in code?

You could try adding 'defer' to your script tag:

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

Or, you could try waiting until the DOM is ready:

$(document).ready(function(){

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

});

hth

have to set AllowSelect:true for IE

jQuery(function ($) {

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

I don't know but you could try this and if it doens't work better why don't you ignore IE and say the page is not available in IE or all feature's aren't avaible, or perhaps you could auto reload the page automatically if the person is using IE

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

And to autoreload the page use following code,

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

I'm sure you can add that or not add it with some PHP code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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