| ||||||||||||
![]() |
Article | |||||||||||
|
||||||||||||
![]() |

โดย สรวุฒิ กอสุวรรณศิริ

<DIV ID="parent1Div">
<DIV ID="child1Div"></DIV>
<DIV ID="child2Div"></DIV>
</DIV>
<STYLE TYPE="text/css">
<!--
#parent1Div {position:absolute; left:100; top:80; width:230; height:120; clip:rect(0,230,120,0); background-color:#C0C0C0; layer-background-color:#C0C0C0;}
#child1Div {position:absolute; left:-20; top:40; width:70; height:70; clip:rect(0,70,70,0); background-color:#FF0000; layer-background-color:#FF0000;}
#child2Div {position:absolute; left:180; top:70; width:70; height:70; clip:rect(0,70,70,0); background-color:#0000FF; layer-background-color:#0000FF;}
-->
</STYLE>
<DIV ID="parent1Div">
<DIV ID="child1Div"></DIV>
<DIV ID="child2Div"></DIV>
</DIV>
ทีนี้ก็มาถึงส่วนสำคัญ การที่เราจะนำไปประยุกต์ใช้ ก็ต้องใช้ JavaScript แต่เราจะใช้ JavaScript ติดต่อกับเลเยอร์ที่อยู่ภายในได้อย่างไร ? สำหรับใน IE มีรูปแบบเหมือนกับการติดต่อกับ Parent Layer เลยครับ
childLayer.style.properyName
แต่ใน Netscape นั้น มีรูปแบบที่แตกต่างกัน มันจะต้องอ้างอิงจาก Parent layer เข้าไป มันจะถือว่า child layer เป็นส่วนหนึ่งของ document ของ parent layer ดังนั้นจึงมีรูปแบบดังนี้
document.parentLayer.document.childLayer.propertyName
document.parent1Div.document.child1Div.document.child2Div.propertyName
จบแล้วครับ แหมง่ายจัง อ่านจบแล้วลองเอาไปใช้ดูนะครับ ผมเชื่อมั่นว่าคุณผู้อ่านสามารถประยุกต์เป็น Script จ๊าบๆได้แน่นอน
![]() |
© copyright 2001 Sorrawut Korsuwansiri | |