简体   繁体   English

jQuery-触发功能使我的页面无需停止即可重新加载

[英]jQuery - trigger function is making my page to reload without stop

    <script type="text/javascript">
    $.noConflict();

    jQuery(document).ready(function($){

        $("#SuperWebF1").click(function(){
          event.stopImmediatePropagation();
        });

        $("#SuperWebF1").click(function(){
        if ($('[name="shipping_method"]', window.parent.document).is(':checked')){
        event.stopPropagation();
        billing.save();

        parent.jQuery("#LoadingDiv").show().delay(4300).fadeOut();
        parent.jQuery("#OutDiv").hide().delay(5000).fadeIn();
        parent.jQuery('#OutDiv').removeClass('outerdiv');
        parent.jQuery('#OutDiv').removeClass('outerdivNoAdress');



        setTimeout(function() {
        if( $('#DisplayMe').length ){
           parent.jQuery('#OutDiv').addClass('OuterDiv1000');
        } else {
           parent.jQuery('#OutDiv').addClass('OuterDiv1000No');
        }
        }, 5100);


        parent.jQuery('#InnerIframe').removeClass('FrameCSS');
        parent.jQuery('#InnerIframe').removeClass('FrameCSSNoAdress');
        parent.jQuery('#InnerIframe').addClass('FrameCSS1000');
    }else {
    alert('Моля, изберете начин на доставка!');
    }   

        })

     $('#SuperWebF1').trigger( "click" );

    });

    </script>

With this code i'm making the button with id SuperWebF1 to be clicked at the load of the page. 使用此代码,我SuperWebF1 ID为SuperWebF1的按钮在页面加载时被单击。

The problem with the script is that the page is not stopping to reload. 脚本的问题在于页面没有停止重新加载。

Can i somehow make stop reloading all the time ? 我可以一直以某种方式停止重新加载吗?

Thanks 谢谢

Add the type="button" to your button tag 将type =“ button”添加到您的按钮标签中

    var billing = {save: function(){}};

    $.noConflict();

    jQuery(document).ready(function($){
        var superWebF1 = $("#SuperWebF1");

        superWebF1.click(function(){
            event.stopImmediatePropagation();
        });

        superWebF1.click(function(){
            if ($('[name="shipping_method"]', window.parent.document).is(':checked')){
                console.log("here");
                event.stopPropagation();
                billing.save();

                parent.jQuery("#LoadingDiv").show().delay(4300).fadeOut();
                parent.jQuery("#OutDiv").hide().delay(5000).fadeIn();
                parent.jQuery('#OutDiv').removeClass('outerdiv');
                parent.jQuery('#OutDiv').removeClass('outerdivNoAdress');



                setTimeout(function() {
                    if( $('#DisplayMe').length ){
                        parent.jQuery('#OutDiv').addClass('OuterDiv1000');
                    } else {
                        parent.jQuery('#OutDiv').addClass('OuterDiv1000No');
                    }
                }, 5100);


                parent.jQuery('#InnerIframe').removeClass('FrameCSS');
                parent.jQuery('#InnerIframe').removeClass('FrameCSSNoAdress');
                parent.jQuery('#InnerIframe').addClass('FrameCSS1000');
            }else {
                alert('Моля, изберете начин на доставка!');
            }

        });

        superWebF1.trigger( "click" );

    });

</script>
<form>
    <input name="shipping_method" type="checkbox" checked><button type="button" id="SuperWebF1">Test</button>
</form>

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

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