html页面与页面之间怎么进行跳转传值

html-css011

html页面与页面之间怎么进行跳转传值,第1张

一、通过<a href="目标网页地址">进行跳转;

二、要传值的话可以在href属性中这样添加:

        href="目标地址?第一个值的名称=值&第二个值的名称=值"

说明:在上面的href属性中:“?”后面接要传的值;

“name=value”表示传值得形式,名称=值;

“&”表示多个值的连接;

看下面一个例子,你应该更明白了:

例:href=“index.html?name=zhangsan&password=123456”

三、简单说一下,在html中这样直接跳转传值没什么意义,因为html无法直接使用。如果是使用jsp的话倒是可以。提醒一句,一般带数据的跳转会经过后台处理后,再进行跳转至另一个页面!

满意的话,请五星好评采纳!O(∩_∩)O~

html是静态页面,可以使用url链接传值,比如a.html和b.html两个页面

a.html中有一个链接

1

<a href="b.html?x=2&y=3">进入b.html</a>

可以使用到js,如下:

a.htm:

1

2

3

4

<form action="b.htm" >

<input name="q" type="text" value="" />

<input type="submit" value="提交" id="" />

</form>

b.htm

<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 = 0i <pairs.lengthi++) {

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>

希望能帮到你哦!