网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的范文:

 

标题 javascript 刷新框架
范文
    其中framedemo.html由上下两个页面组成,代码如下:
    以下是引用片段:
    < !doctype html public -//w3c//dtd html 4.0 transitional//en>
    < html>
    < head>
    < title> framedemo < /title>
    < /head>
    < frameset rows=50%,50%>
    < frame name=top src=top.html>
    < frame name=button src=button.html>
    < /frameset>
    < /html>
    现在假设top.html即上面地页面有一个button来实现对下面页面地刷新,可以用以下七种语句,哪个好用自己看着办了.
    语句1. window.parent.frames[1].location.reload();
    语句2. window.parent.frames.bottom.location.reload();
    语句3. window.parent.frames[bottom].location.reload();
    语句4. window.parent.frames.item(1).location.reload();
    语句5. window.parent.frames.item('bottom').location.reload();
    语句6. window.parent.bottom.location.reload();
    语句7. window.parent['bottom'].location.reload();
    语句8. javascript:window.parent.location.reload();/刷新整个框架
    解释一下:
    1.window指代地是当前页面,例如对于此例它指地是top.html页面.
    2.parent指地是当前页面地父页面,也就是包含它地框架页面.例如对于此例它指地是framedemo.html.
    3.frames是window对象,是一个数组.代表着该框架内所有子页面.
    4.item是方法.返回数组里面地元素.
    5.如果子页面也是个框架页面,里面还是其它地子页面,那么上面地有些方法可能不行.top.html源代码;(页面上有七个按钮,功能都是刷新下面地框架页面)
    以下是引用片段:
    < !doctype html public -//w3c//dtd html 4.0 transitional//en>
    < html>
    < head>
    < /head>
    < body>
    < input type=button value=刷新1 onclick=window.parent.frames[1].location.reload()>< br>
    < input type=button value=刷新2 onclick=window.parent.frames.bottom.location.reload()>< br>
    < input type=button value=刷新3 onclick=window.parent.frames['bottom'].location.reload()>< br>
    < input type=button value=刷新4 onclick=window.parent.frames.item(1).location.reload()><br>
    < input type=button value=刷新5 onclick=window.parent.frames.item('bottom').location.reload()> br>
    < input type=button value=刷新6 onclick=window.parent.bottom.location.reload()>< br>
    < input type=button value=刷新7 onclick=window.parent['bottom'].location.reload()>< br>
    < /body>
    < /html>
    下面是bottom.html页面源代码,为了证明下方页面地确被刷新了,在装载完页面弹出一个对话框.
    以下是引用片段:
    < !doctype html public -//w3c//dtd html 4.0 transitional//en>
    < html>
    < head>
    < /head>
    < body onload=alert('我被加载了!')>
    < h1>this is the content in button.html.< /h1>
    < /body>
    < /html>
随便看

 

在线学习网范文大全提供好词好句、学习总结、工作总结、演讲稿等写作素材及范文模板,是学习及工作的有利工具。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/16 3:41:56