Khirthan
Khirthan

Reputation: 197

Window.open makes the page into a popup block

Below is my code for opening the button into a new page, but there are more complexity on the on click function. Here the post process also happens, which makes the window.open in as popup block.

I have tried to remove the post function and tried and the new page works perfectly. could anybody help out in this issue.

$('#catalog_demo_button a').click(function(e) {         
        var curEmailId = $('#field-email').val();           
        var validemail = validateEmail(curEmailId);
        if (validemail) 
        {   
        RSUI.util.setCookie("curEmailIdsc", curEmailId);
        $.post($("#targetform").val(), 
        {
            email : $('#field-email').val(),
            demo_lang : $('#selectedLang').val(),
            cis_name : $("#cis_name").val(),
            website : $("#website").val(),
            form_type : "demo",
            demo_type : $("#form_type").val(),
            form_url : $("#form_url").val(),
            cid : $.trim(RSUI.util.getCookie('affiliate'))
        },function(data) 
        {
            if (data != "")
            {
                data = eval("("+data+")");
                if (data[0].cisFlag == "true")                                  
                {                           
                    s.events="event19";
                    s.t();
                    delete s.events;
                    s.sendFormEvent('s', s.pageName, "Demo Email Form");
                    adconionConversionCall();   



                    var demolangid = $("[name=language_code]").val();
                    URL= 'url'+demolangid; 
                        if(demolangid == 'ENG' || demolangid == 'ESC' || demolangid == 'ESP' || demolangid == 'DEU' || demolangid == 'FRA' || demolangid == 'ITA' || demolangid == 'SVE')   
                            $('#demo').overlay().load();
                        else
                            window.open(URL,'_blank')
                            $("#demoform a.close").click();
                    }
                else {
                    s.sendFormEvent('e', s.pageName, "Demo Email Form", "Email Submission Failed");
                }
            }   
        }, "");
    }
        else 
        {
            $("#field-email").val(errorEmailText);
            $('#field-email').css('border', '1px solid red');
            s.sendFormEvent('e', s.pageName, "Demo Email Form", "field-email");
        }
    });

Upvotes: 1

Views: 965

Answers (1)

René
René

Reputation: 6176

Popups are blocked when not invoked by a user action. Your window.open is not in the user action but in the POST success callback.

You should either make the post synchronous and do the window.open from outside the POST success(untested, but sounds logical) or first open the popup and fill it in later.

Upvotes: 1

Related Questions