设置滚动轴的位置

 

// iframe 
把iframe解释成“浏览器中的浏览器“很是恰当
<iframe frameborder=0 width=170 height=100 marginheight=0 marginwidth=0 scrolling=no 
 src=http://www.163.com></iframe>
 
下面的例子返回了对 IFRAME 包含的文档的 all 集合的引用。
var collAll = document.frames("IFrame1").document.all

HTML <form> 标签的 target 属性
<form action="form_action.asp" method="get" target="_blank">

// 重要知识点:
_blank  在新窗口中打开;
_self   默认值,在相同的框架中打开
_parent 在父框架集中打开
_top    在整个窗口打开
framename 在指定的框架中打开[ iframe 之类的]

1) 如何在页面设置滚动轴的位置:
<button οnclick="window.location.reload();">reload</button>  
<button οnclick="window.document.execCommand('Refresh');">reload</button> 

javascript 中的 document.execCommand()的用法:
调用execCommand() 可以实现浏览器菜单的很多功能,如果保存文件,打开新文件,撤销,重复操作...
可以很容易的实现网页中的文本编辑器,如果灵活应用,可以很好的辅助我们完成各种项目...<IE>

刷新网页用的是: window.location.reload();
http://blog.csdn.net/woshinia/article/details/18664903 

// 页面中各种宽度设置
http://www.cnblogs.com/yuteng/articles/1894578.html
height, clientHeight, scrollHeight, offsetHeight 区别

height: height高度跟其它的高度有点不一样,在 javascript 中它属于对象的 style 对象属性中的一个成员
它的值是一个字符类型的,另外三个高度的值是 int 类型的,它们的对象的属性,因此这样 document.body.height
就会提示 undefined, 而必须写成 document.body.style.height,height是最简单的了,不必去考虑是否有滚动条
及边框等.

// document.body.clientHeight, clientHeight[可见区域]的高度,不包括 border 的宽度,如果区域内带有滚动条
还应该减去横向滚动条不可用的高度,正常是是 17px, 其实就是滚动条的可滚动的部分了,其实 clientHeight 与
Height 的高度差不多,如果不带滚动条的话他们的值是不一样的, 如果带有滚动条就会比 Height 少 17px

// document.body.scrollHeight 比较常用,只整个页面可以达到的最大高度;[因为要定位滚动轴的位置]

// document.body.offsetHeight 表示是自身的高度

// http://www.w3school.com.cn/jsref/met_win_scrollto.asp
scrollTo 方法<HTML DON Window 对象>
scrollTo() 方法可把内容滚动到指定的坐标; scrollTo(xpos, ypos)
要在窗口文档显示区左上角显示的文档的 x 坐标
要在窗口文档显示区左上角显示的文档的 y 坐标

<script type="text/javascript">
function scrollWindow()
{ 
   // 滚动条居中显示
   window.scrollTo(0,document.body.scrollHeight/2)
   // 滚动条处于底部
   window.scrollTo(0,document.body.scrollHeight)
}
</script>

<script language="javascript">
<!--
//  获取当前文件名
function getFileName()
{
    var url = this.location.href;
    var pos = url.lastIndexOf("/");
    if(pos == -1)
    pos = url.lastIndexOf("\\");
    var filename = url.substr(pos+1);
    return filename;
}

function fnLoad()
{
    with(window.document.body)
    {
        addBehavior ("#default#userData");    // 使得body元素可以支持userdate
        load("scrollState" + getFileName());    // 获取以前保存在userdate中的状态
        if (sFirstEnter=="0")
        {
            scrollLeft = getAttribute("scrollLeft");    // 滚动条左位置
            scrollTop = getAttribute("scrollTop");
        }
    }
}
function fnUnload()
{
    with(window.document.body)
    {
        setAttribute("scrollLeft",scrollLeft);
        setAttribute("scrollTop",scrollTop);
        save("scrollState" + getFileName());    
        // 防止受其他文件的userdate数据影响,所以将文件名加上了
        // userdate里的数据是不能跨目录访问的
    }
}

window.onload = fnLoad;
window.onunload = fnUnload;
// -->
</script> 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值