Reputation: 37
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);
}
}
}
Upvotes: 0
Views: 191
Reputation: 150040
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";
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()
.
Upvotes: 1
Reputation: 1559
Unless I misunderstand your question you just need a:
window.location = 'http://www.domain.com';
line inside your if (resp.result=="success"){
block.
Upvotes: 1