0

Please give me your lights. I am using some javascript for the behavior of one form. As you can see on the code that i provide below, if the form is submited successfully, a message is displayed. What i need is instead of this message, a URL to open. I guess the change has to be made in the if (resp.result=="success") . Note also that the else condition have to be the same

function mce_success_cb(resp){
    $('#mce-success-response').hide();
    $('#mce-error-response').hide();
    if (resp.result=="success"){
        $('#mce-'+resp.result+'-response').show();
        $('#mce-'+resp.result+'-response').html(resp.msg);
        $('#mc-embedded-subscribe-form').each(function(){
            this.reset();
        });
    } else {
        var index = -1;
        var msg;
        try {
            var parts = resp.msg.split(' - ',2);
            if (parts[1]==undefined){
                msg = resp.msg;
            } else {
                i = parseInt(parts[0]);
                if (i.toString() == parts[0]){
                    index = parts[0];
                    msg = parts[1];
                } else {
                    index = -1;
                    msg = resp.msg;
                }
            }
        } catch(e){
            index = -1;
            msg = resp.msg;
        }
        try{
            if (index== -1){
                $('#mce-'+resp.result+'-response').show();
                $('#mce-'+resp.result+'-response').html(msg);            
            } else {
                err_id = 'mce_tmp_error_msg';
                html = '<div id="'+err_id+'" style="'+err_style+'"> '+msg+'</div>';

                var input_id = '#mc_embed_signup';
                var f = $(input_id);
                if (ftypes[index]=='address'){
                    input_id = '#mce-'+fnames[index]+'-addr1';
                    f = $(input_id).parent().parent().get(0);
                } else if (ftypes[index]=='date'){
                    input_id = '#mce-'+fnames[index]+'-month';
                    f = $(input_id).parent().parent().get(0);
                } else {
                    input_id = '#mce-'+fnames[index];
                    f = $().parent(input_id).get(0);
                }
                if (f){
                    $(f).append(html);
                    $(input_id).focus();
                } else {
                    $('#mce-'+resp.result+'-response').show();
                    $('#mce-'+resp.result+'-response').html(msg);
                }
            }
        } catch(e){
            $('#mce-'+resp.result+'-response').show();
            $('#mce-'+resp.result+'-response').html(msg);
        }
    }
}
0

3 Answers 3

2

How about this?

window.location = "http://www.example.com";
Sign up to request clarification or add additional context in comments.

Comments

1

What i need is instead of this message, a URL to open.

OK, so replace the part of the code you don't need with this:

window.location = "yourURLhere";

More information from MDN.

If your intention was to open a page in a new window then try this:

window.open("yourURLhere", "AWindowName", strWindowFeatures);

Where strWindowFeatures is an optional parameter that lets you set the size, position, etc. for the new window. See MDN for complete doco on window.open().

1 Comment

Sure that works! the window.location command is only opening in new window? are any options for parent?
1

Unless I misunderstand your question you just need a:

window.location = 'http://www.domain.com';

line inside your if (resp.result=="success"){ block.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.