HTML 中 URL 传值。

来源:互联网 发布:施工图设计优化 编辑:程序博客网 时间:2024/06/05 02:25

a.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title></head><body><script>function a(){var input1 = document.getElementById("inputid");window.open("file:///C:/Users/So/Desktop/aw/b.html?inputStr=" + input1.value);//传入参数(其中,括号里面为程序文件地址)}</script><input type = "text" id = "inputid"><input type = "button" onclick = "a()" value = "提交"><input onclick='window.location="view-source:" + window.location.href' type="button" value="查看源文件" name="Button7"></body></html>


b.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><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 b = request.QueryString("inputStr");alert(b);</script><input onclick='window.location="view-source:" + window.location.href' type="button" value="查看源文件" name="Button7"></body></html>



0 0
原创粉丝点击