//a.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-loose.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title></title> 
<style type="text/css">
</style>
<script>
function aChange(n){
document.getElementById("console").innerHTML = document.getElementById("console").innerHTML + n;
}
</script>
</head>
<body>
<iframe id="ffff" width="500" height="300"></iframe>
<div id="console"></div>
</body> 
</html>
<script>
document.getElementById("ffff").src = "b.html";
</script>
//b.html
<html>
<head>
<title>myPage</title>  
<script>
function change(n){
window.parent.aChange(n);
}
</script>
</head>
<body>
<span onClick="change(this.innerHTML)" style="background-color:#066;">click me!</span>
</body>
</html>

解决方案 »

  1.   

    b.asp中 js用window.parent.方法()可以直接获取到父窗体的方法
    同样也可以通过window.parent.变量为父窗体变量赋值
      

  2.   

    加上操作变量的:
    ////////////////////////////////////////////////////////////////a.html
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-loose.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
    <title></title> 
    <style type="text/css">
    </style>
    <script>
    var num = 0;
    function aChange(n,count){
    num = count;
    document.getElementById("console").innerHTML = document.getElementById("console").innerHTML + n+num+"次";
    }
    </script>
    </head>
    <body>
    <iframe id="ffff" width="500" height="300"></iframe>
    <div id="console"></div>
    </body> 
    </html>
    <script>
    document.getElementById("ffff").src = "b.html";
    </script>
    //////////////////////////////////////////////////////////////b.html
    <html>
    <head>
    <title>myPage</title>  
    <script>
    var count = 0;
    function change(n){
    count++;
    window.parent.aChange(n,count);
    }
    </script>
    </head>
    <body>
    <span onClick="change(this.innerHTML)" style="background-color:#066;">click me!</span>
    </body>
    </html>
      

  3.   

    <script>alert("hello")</script>