asp.net 一个页面嵌入iframe 如何与其他页面传值
1个回答
展开全部
两个iframe之间js互访
index.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>iframe</title>
<script>
function alertSth(alertValue)
{
alert(alertValue);
}
</script>
</head>
<body>
<iframe align="center" height="200" width="200" src="ifmA.htm" id="ifmA"></iframe>
<iframe align="center" height="200" width="200" src="ifmB.htm" id="ifmB"></iframe>
</body>
</html>
ifmA.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>iframeA</title>
<script>
function callParent()
{
parent.alertSth("i am iframeA");
}
function callIFrame()
{
parent.ifmB.alertB();
}
</script>
</head>
<body bgcolor="#999999">
<a href="#" onClick="callParent();">click me to call parent</a>
<br>
<a href="#" onClick="callIFrame();">click me to call iframe B</a>
</body>
</html>
ifmB.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>iframeB</title>
<script>
function alertB()
{
alert("I AM IFRAME B");
}
</script>
</head>
<body bgcolor="#333333">
</body>
</html>
index.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>iframe</title>
<script>
function alertSth(alertValue)
{
alert(alertValue);
}
</script>
</head>
<body>
<iframe align="center" height="200" width="200" src="ifmA.htm" id="ifmA"></iframe>
<iframe align="center" height="200" width="200" src="ifmB.htm" id="ifmB"></iframe>
</body>
</html>
ifmA.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>iframeA</title>
<script>
function callParent()
{
parent.alertSth("i am iframeA");
}
function callIFrame()
{
parent.ifmB.alertB();
}
</script>
</head>
<body bgcolor="#999999">
<a href="#" onClick="callParent();">click me to call parent</a>
<br>
<a href="#" onClick="callIFrame();">click me to call iframe B</a>
</body>
</html>
ifmB.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>iframeB</title>
<script>
function alertB()
{
alert("I AM IFRAME B");
}
</script>
</head>
<body bgcolor="#333333">
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询