摘要方法一:
http://blog.sina.com.cn/s/blog_664c8e480100izbw.html
index1.htm页面
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<SCRIPT LANGUAGE="JavaScript">
</SCRIPT>
<style>
.input7 {color: #999;width:145px;height:20px;border: 1px solid #CCCCCC; font-size:12px;background-color: #fff;}
</style>
</HEAD>
<BODY>
<input type="text" id="name" class="input7">
<input type="button" value="OK" οnclick="show()"/>
</BODY>
</HTML>
index2页面:
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<SCRIPT LANGUAGE="JavaScript">
function getvalue(name){
</SCRIPT>
</HEAD>
<BODY>
<input type="button" οnclick="getvalue('show')" value="GetValue"/>
</BODY>
</HTML>
摘要方法二:
例如
a.htm:
1
2
3
4
|
< form action = "b.htm" > < input name = "q" type = "text" value = "" /> < input type = "submit" value = "提交" id = "" /> </ form > |
b.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
<html> <body> <div id= "qbox" ></div> <script type= "text/javascript" > function getArgs() { var args = {}; var query = location.search.substring(1); // Get query string var pairs = query.split( "&" ); // Break at ampersand for ( var i = 0; i < pairs.length; i++) { var pos = pairs[i].indexOf( '=' ); // Look for "name=value" if (pos == -1) continue ; // If not found, skip var argname = pairs[i].substring(0,pos); // Extract the name var value = pairs[i].substring(pos+1); // Extract the value value = decodeURIComponent(value); // Decode it, if needed args[argname] = value; // Store as a property } return args; // Return the object } var str =getArgs(); alert(str[ 'q' ]); //和input的name对应取值, document.getElementById( "qbox" ).innerHTML = str[ 'q' ]; //然后赋值给DIV </script> </body> </html> |