原文出处:http://www.cnblogs.com/greywardens/archive/2013/01/26/2878232.html
用jQuery时,可如下设置:
form表单:
1 <form name="myform" id="myform" action="ssss" method="post" onsubmit="getUrl();">
javascript方法:
1 <script type="text/javascript"> 2 function getUrl(){ 3 $('form').attr('action','new_url'); 4 } 5 </script>
或者用单纯的javascript:
1 function test1(){ 2 alert(document.myform.action);//返回值:http://localhost:8080/XXX/ssss 3 alert(document.myform.attributes["action"].value);//返回值:ssss 与上一行有区别 4 // 以下三行,随便哪一行都行 5 document.getElementById('myform').action=‘new_url’; 6 document.myform.action=‘new_url’; 7 document.myform.attributes["action"].value = 'new_url'; 8 }