日期:2014-05-16 浏览次数:20583 次
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>a.html</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript"> var aPageContent = "a页面内容"; </script> </head> <body style="background-color: blue;"> a页面:<br /> <iframe name="cIframe" id="cIframe" src="http://www.hck.com:8080/WebTest/c.html"></iframe> <br /> <br /> <iframe name="dIframe" id="dIframe" src="http://www.hck.com:8080/WebTest/d.html"></iframe> </body> </html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>a.html</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript"> function test() { alert(top.aPageContent); } </script> </head> <body> b页面:a、b同域 <button onclick="javascript:test();">调用A页面的内容</button> </body> </html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>a.html</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript"> var cccc = "c页面的内容"; </script> </head> <body> c页面: <iframe src="http://www.xu.com:8080/WebTest/b.html"></iframe> </body> </html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>a.html</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript"> function test() { alert(top.frames[0].cccc); } </script> </head> <body> d页面:c、d同域 <button onclick="javascript:test();">调用c页面的内容</button> </body> </html>