---
title: "js以post方式打开一个新的web页面"
author: "莫欺少年穷Java"
date: "2016-07-07T11:26:02Z"
tags: []
categories: ["编程语言"]
slug: "js-post-web"
draft: false
lastmod: "2016-07-07T11:26:02Z"
id: 2309757
url: "https://hejiawangjava.iteye.com/blog/2309757"
---

```
        /**
	 * 以post方式打开另一个新页面 add Hejiawang by 2016.07.07
	 */
	function postOpenWindow(URL, PARAMS) { 
		var temp_form = document.createElement("form");
		temp_form .action = URL;
		temp_form .target = "_blank";
		temp_form .method = "post";
		temp_form .style.display = "none"; 
		for (var x in PARAMS) { 
			var opt = document.createElement("textarea");
			opt.name = x;
			opt.value = PARAMS[x];
			temp_form .appendChild(opt);
		}
		document.body.appendChild(temp_form);
		temp_form .submit();
	}
```

 使用示例：

```
post('url',{aa :aa,bb:bb});
```