js向html传递参数

来源:互联网 发布:淘宝返现怎么查询 编辑:程序博客网 时间:2024/06/15 11:30
  1.  js 文件function a(){  
  2.     show_modelId += model_id;  
  3.     window.open("a.htm?show_modelId="+show_modelId+"",'','height=400,width=800,location=yes');  
  4. }   把show_modelId 的值传递到页面   
  5. a.html  
[html] view plaincopyprint?
  1. <input type="text" name="hidden_ID"  ID="hidden_ID" style="width: 300px;"/>  
  2.   <script>  
  3. //获得参数的方法  
  4. var request =  
  5. {  
  6. QueryString : function(val)  
  7. {  
  8. var uri = window.location.search;  
  9. var re = new RegExp("" +val+ "=([^&?]*)", "ig");  
  10. return ((uri.match(re))?(uri.match(re)[0].substr(val.length+1)):null);  
  11. }  
  12. }  
  13. </script> <script>//调用方法获得参数var modelid = request.QueryString("show_modelId");document.getElementById("hidden_ID").value=modelid;</script>   

0 0
原创粉丝点击