---
title: "html界面之间传参"
author: "tracyjuan"
date: "2015-03-05T17:54:23Z"
tags: []
categories: ["Web前端"]
slug: "html"
draft: false
lastmod: "2015-03-05T17:54:23Z"
id: 2189170
url: "https://tracyjuan.iteye.com/blog/2189170"
---

1.从index.html界面跳转到search.html界面，传递两个参数searchType和searchContent
window.open("http://localhost:8080/TestProject/search.html?searchType=" + searchType+"&searchContent="+searchContent);
2.在search.html界面接收参数
//获得参数的方法
	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);
		}
	}
//调用方法获得参数
var searchType = request.QueryString("searchType");
var searchContent = request.QueryString("searchContent");
alert(searchType);
alert(searchContent);
3.传递过来的参数如果包含中文，window.open直接对中文进行了编码，可以用decodeURIComponent(searchContent)得到解码后的中文