第一个页面中有两个图片,当点击的时候能在第二个页面中获得它的属性值()通过js进行传值:
第一个页面:
[html]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function test(){
var img1= ("img1");
var img2= ("img2");
//获得alt的属性
var parm1=("alt");
var parm2=("alt");
//url
img1.οnclick=function(){
var myurl=""+"?"+"parm1="+parm1;
(myurl);
}
img2.οnclick=function(){
var myurl=""+"?"+"parm2="+parm2;
(myurl);
}
}
</script>
</head>
<body οnlοad="test();">
<img src="" alt="myimg1">
<img src="" alt="myimg2">
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function test(){
var img1= ("img1");
var img2= ("img2");
//获得alt的属性
var parm1=("alt");
var parm2=("alt");
//url
img1.οnclick=function(){
var myurl=""+"?"+"parm1="+parm1;
(myurl);
}
img2.οnclick=function(){
var myurl=""+"?"+"parm2="+parm2;
(myurl);
}
}
</script>
</head>
<body οnlοad="test();">
<img src="" alt="myimg1">
<img src="" alt="myimg2">
</body>
</html>
第二个页面:
[html]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test2</title>
<script type="text/javascript">
function getvalue()
{
///?parm1=myimg1&parm2=myimg2
//获得第一个属性
var url=;
var tmp1=("?")[1];
var tmp2=("&")[0];
var tmp3=("=")[1];
var parm1=tmp3;
//获得第二个属性
/*
var tmp9=("?")[1];
var tmp4=("&")[1];
var tmp5=("=")[1];
var parm2=tmp5;
*/
var inhtml= ("inhtml");
=parm1;
//alert(parm1);
}
</script>
</head>
<body οnlοad="getvalue();">
<h2>测试</h2>
<span > </span>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test2</title>
<script type="text/javascript">
function getvalue()
{
///?parm1=myimg1&parm2=myimg2
//获得第一个属性
var url=;
var tmp1=url.split("?")[1];
var tmp2=("&")[0];
var tmp3=("=")[1];
var parm1=tmp3;
//获得第二个属性
/*
var tmp9=("?")[1];
var tmp4=("&")[1];
var tmp5=("=")[1];
var parm2=tmp5;
*/
var inhtml= ("inhtml");
=parm1;
//alert(parm1);
}
</script>
</head>
<body οnlοad="getvalue();">
<h2>测试</h2>
<span > </span>
</body>
</html>
<..............................................................................................................................>
<
script
>
function dd(x){
var y="?line number4 index3 alt1" style="font-family:Monaco,Menlo,Consolas,'Courier New',monospace; line-height:14.3px; font-size:13px; color:rgb(51,51,51); border:0px!important; bottom:auto!important; float:none!important; left:auto!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; min-height:auto!important; margin:0px!important; padding:0px 1em!important; background-color:rgb(245,245,245)">
=y;//打开?id=参数x
}
</
script
>
<
div
onclick
=
"dd('abc');"
>点击</
div
>
通过url传参
如果是HTML页面的话JS传到新页面就='?id=100';然后页面的JS就<div ></div>
1
2
3
|
<script>
(
"s"
).innerHTML=(
'?'
)[1];
</script>
|
如果是想要实现AJAX在a页面传参数到b页面并且在a页面的层显示b页面执行参数的结果的话就用AJAX了
这个写起来太多,给你JQUERY的
1
2
3
4
5
6
|
<div id=
"a"
></div>
$(
"#a"
).load(
"?id=100"
);
//或者
$.get(
"?id=100"
,
function
(data){
$(
"#a"
).html(data);
})
|