轉自:http://blog.163.com/yangzhanghui_job/blog/static/179575062201271624839972/
aa.html 往 bb.html 傳參 aa.html 文件代碼: <html> <head> </head> <body> <script> function submit() { var input1 = document.getElementById("inputid"); window.open("bb.html?inputStr=" + input1.value);//傳入參數 } </script> <input type = "text" id = "inputid"> <input type = "button" onclick = "submit()" value = "提交"> </body> </html> _____________________________________________________ bb.html 文件代碼: <html> <head> <script> //獲得參數的方法 var request = { QueryString : function(val) { var uri = window.location.search; var re = new RegExp("" +val+ "=([^&?]*)", "ig"); return ((uri.match(re))?(uri.match(re)[0].substr(val.length+1)):null); } } </script> </head> <body> <script> //調用方法獲得參數 var rt = request.QueryString("inputStr"); alert(rt); </script> </body> </html>