javascript - wierd way to get chrome, IE 8 and firefox to submit the same form -


this way found 3 browsers submit form without problems. there obvious reason why so? more elegant solution this? i'm using jquery 1.9. chrome odd man out here, code in else sufficient submit via ie , firefox.

function submitformbypost(actionname){       $("#eventaction").val(actionname);       var is_chrome = navigator.useragent.tolowercase().indexof('chrome') > -1;      if(is_chrome){           document.getelementbyid('myform').method='post';           document.getelementbyid('myform').submit();      }      else{           document.forms[0].method='post';           document.forms[0].submit();       }  } 

the way works in chrome work in others also, use that:

function submitformbypost(actionname){    $("#eventaction").val(actionname);   var frm = document.getelementbyid('myform');   frm.method = 'post';   frm.submit(); } 

or using jquery way:

function submitformbypost(actionname){    $("#eventaction").val(actionname);   $('#myform').attr('method', 'post').submit(); } 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -