2009-10-20 35 views

回答

0

的index.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<title>Untitled Document</title> 
</head> 
<frameset rows="80,*" frameborder="no" border="0" framespacing="0"> 
    <frame src="top.html" name="topFrame" scrolling="No" noresize="noresize" id="topFrame" title="topFrame" /> 
    <frame src="cont.html" name="mainFrame" id="mainFrame" title="mainFrame" /> 
</frameset> 
<noframes><body> 
</body> 
</noframes></html> 

的top.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=iso-8859-1" /> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script> 
<script language="JavaScript"> 

$(function(){ 

    $("#test").click(function(){ 
     alert($(window.parent.document.frames["mainFrame"].document).find("body").html()); 
     $(window.parent.document.frames["mainFrame"].document).find("body").html("<div>this is a test</div>"); 
     alert($(window.parent.document.frames["mainFrame"].document).find("body").html()); 
    }); 
}); 

</script> 
</head> 
<body> 
    <button id="test">test</button> 
</body> 
</html> 

cont.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=iso-8859-1" /> 
</head> 
<body> 
    <div>empty</div> 
</body> 
</html> 
相關問題