提交页面的定位--scrollIntoView的用法
object.scrollIntoView( [bAlignToTop])
Parameters
bAlignToTop Optional. Boolean that specifies one of the following values:
true Default. Scrolls the object so that top of the object is visible at the top of the window. false Scrolls the object so that the bottom of the object is visible at the bottom of the window.
Return Value
No return value.
Remarks
The scrollIntoView method is useful for immediately showing the user the result of some action without requiring the user to manually scroll through the document to find the result.
Depending on the size of the given object and the current window, this method might not be able to put the item at the very top or very bottom, but will position the object as close to the requested position as possible.
Example
This example uses the scrollIntoView method to underline the content of the document's fifth paragraph and scroll it into view at the top of the window.
HideExample
var coll = document.all.tags("P"); if (coll.length >= 5) { coll(4).style.textDecoration = "underline"; coll(4).scrollIntoView(true); }
Standards Information
There is no public standard that applies to this method.
Applies To
INPUT type=ra... Platform Version Win16: 4.0 Win32: 4.0 Windows CE: 4.0 Unix: 4.0 Mac: 4.0 Version data is listed when the mouse hovers over a link, or the link has focus. A, ADDRESS, APPLET, AREA, B, BIG, BLOCKQUOTE, BR, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, controlRange, CUSTOM, DD, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, hn, HR, I, IFRAME, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, KBD, LABEL, LEGEND, LI, LISTING, MAP, MARQUEE, MENU, NOBR, OBJECT, OL, P, PLAINTEXT, PRE, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TextRange, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, WBR, XMP Move the mouse pointer over an element in the Applies To list to display availability information for the listed platforms.
二、在.Net中的应用
1、定位指定控件
/// <summary>
/// 定位txtCode控件
/// </summary>
private void Scroll()
{
string s="<script>function window.onload(){document.all('"+this.txtCode.ClientID+"').scrollIntoView();}</script>";
Page.RegisterStartupScript("",s);
}
2、定位指定DataGrid列
<div style="BORDER:0px;PADDING:0px;MARGIN:0px;OVERFLOW:scroll;WIDTH:600px;HEIGHT:200px" align="center">现在给出一种简单的办法(其他的一些利用锚点等办法都比较复杂)
private void Scroll(int index)
{
string s="<script>function window.onload(){document.all('"+this.DataGrid1.ClientID+"').rows["+index+"].scrollIntoView();}</script>";
Page.RegisterStartupScript("",s);
}写了一个方法,其中DataGrid1换成自己的DataGrid的ID,这个方法传递进去的参数就是行号,也就是e.Item.ItemIndex。
比如在编辑操作的时候会写this.DataGrid1.EditItemIndex=e.Item.ItemIndex;
在此语句的以前加入Scroll(e.Item.ItemIndex);就可以了
同样在更新操作的时候写为Scroll(e.Item.ItemIndex);this.DataGrid1.EditItemIndex=-1;绑定;
相关文章
ASP.NET MVC制作404跳转实例(非302和200)
本篇文章主要介绍了ASP.NET MVC制作404跳转实例(非302和200) ,具有一定的参考价值,感兴趣的小伙伴们可以参考一下2017-04-04
.Net Core中使用ref和Span<T>提高程序性能的实现代码
这篇文章主要介绍了.Net Core中使用ref和Span<T>提高程序性能的简单实现代码,需要的朋友可以参考下2017-05-05
Net5 WorkService 继承 Quarzt 及 Net5处理文件上传功能
这篇文章主要介绍了Net5 WorkService 继承 Quarzt 以及 Net5处理文件上传,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2022-02-02
.NET下为百度文本编辑器UEditor增加图片删除功能示例
今天下载了目前最新版1.2.5为版本看更新记录,主要是对表格做个修改,我下载用上,上传图片的删除功能给取消了,下面与大家分享下增加图片删除功能示例2013-05-05
.NET中TextBox控件设置ReadOnly=true后台取不到值三种解决方法
当TextBox设置了ReadOnly=true后要是在前台为控件添加了值,后台是取不到的,值为空,多么郁闷的一个问题经过尝试,发现可以通过如下的方式解决这个问题.感兴趣的朋友可以了解下2013-02-02
ASP.NET网站管理系统退出 清除浏览器缓存,Session的代码
管理系统退出登陆后,将网址重新输入后还会看到用户登陆后的界面,为了解决这个问题,我采用了以下方法,需要的朋友可以参考下2012-05-05


最新评论