يمكنك فهم اختبار الكود التالي على النحو التالي:
1.html:
نسخ رمز رمز على النحو التالي:
<!
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text /html ؛ charset = gb2312" /> />
<title> وثيقة غير متوفرة </title>
</head>
<body>
<div> ===================== ملاحظة: يبدأ الاختبار من هنا ============== ==== <= < /div>
<p id = "pox"> المستخدم لاختبار عنصر الوصول الفرعي إلى النافذة الأصل </p>
<div> ======================== Iframe Line ================== = </div>
<iframe src = "a.html" frameborder = "0" id = "framea" name = "framea"> </frame>
<iframe src = "b.html" name = "iframeb" frameborder = "0" id = "frambb"> </frame>
<div> ======================== Iframe Line ================== = </div>
<p> تعال أولاً لإظهار: طريقة أو عنصر في النافذة الأصل التي تصل إلى نافذة الطفل </p>
<p> الملخص: تعتمد طريقة زيارة الريف الفرعي للنافذة الأصل بطريقة مختلفة وعنصر </p>
<type type = "button" onClick = "Framediv ()" value = "عنصر معين في نافذة الأصل يصل إلى العنصر" /> /> />
<type type = "button" onClick = "FrameFun ()" value = "طريقة للوصول إلى نافذة الأصل" /> /> />
<script type = "text/javaScript">
// الوصول الفرعي للوفير إلى طريقة النافذة الأصل
وظيفة testp (ss) {
تنبيه (SS)
}
// احصل على عنصر iFrame
وظيفة getiframe (id) {
return document.getElementById (id) .ContentWindow.document ؛
}
// نافذة الأب الوصول إلى عنصر الريف الفرعي
وظيفة Framediv () {
getiframe ("Framea").
//window.frames ["iframea"].
}
// Woxt Window Access the Sub -window Method
وظيفة FrameFun () {
//getiframe="frameb").getsfun () ؛ // لا يمكن الوصول إلى طريقة في هذا النموذج في هذا النموذج
// window.frames ["iframeb"].
ALERT (window.frames ["iframeb"]. getSfun ()) ؛
}
</script>
</body>
</html>
A.HTML
نسخ رمز رمز على النحو التالي:
<!
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text /html ؛ charset = gb2312" /> />
<title> وثيقة غير متوفرة </title>
</head>
<body>
<div id = "ooxx"> المستخدم لاختبار عنصر معين في النافذة الأصل للوصول إلى عنصر معين في الريف الفرعي </div>
<p id = "divooxx"> المستخدم لاختبار عنصر معين في النافذة B للوصول إلى النافذة A </p>
<p> 1.
<type type = "button" onClight = "FrametOpDiv ()" value = "sub -window للوصول إلى عنصر معين في النافذة الأصل" /> />
<type type = "button" onClick = "FrametOpFun ()" value = "نافذة صغيرة للوصول باستخدام النافذة الأصل" /> />
<script type = "text/javaScript">
// sub -window الوصول إلى عنصر معين في النافذة الأصل
وظيفة FrametOpDiv () {
parent.document.getElementByid ("pox").
parent.document.getElementByid ("pox").
}
// الوصول الفرعي للوفير إلى طريقة النافذة الأصل
وظيفة FrametOpfun (SS) {
parent.testp ("ssss") ؛
}
// الطريقة المستخدمة لاختبار إمكانية الوصول
وظيفة testba () {)
تنبيه ("طريقة لاختبار إمكانية الوصول إلى iframeb")
}
</script>
</body>
</html>
B.HTML
نسخ رمز رمز على النحو التالي:
<!
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text /html ؛ charset = gb2312" /> />
<title> وثيقة غير متوفرة </title>
</head>
<body>
<p> اثنان: اختبار طريقة أو عنصر بين الرياح الفرعية الاختبار </p>
<type type = "button" value = "sub -window B الوصول إلى عنصر معين في الريف الفرعي" onClick = "FrametFramediv ()" /> />
<type type = "button" value = "sub -window B قم بزيارة طريقة من الريف الفرعي A" onClick = "FrametFrameFun ()" /> />
<script type = "text/javaScript">
// sub -window B الوصول إلى عنصر معين في الريف الفرعي أ
وظيفة frametframediv () {{
//parent.document.getElementByid.com
//parent.document.getElementByid.com
var _bframe = parent.getiframe ("Framea") ؛
_bframe.getElementByid ("divooxx").
_bframe.getElementByid ("divooxx").
}
// النافذة الصغيرة ب الوصول إلى طريقة من الريف الفرعي أ
دالة frametframefun () {{
window.parent.frames ["Framea"].
}
</script>
<script type = "text/javaScript">
وظيفة getSfun () {
إرجاع "SSSSSS" ؛
}
// getFun ()
</script>
</body>
</html>