提交頁(yè)面的定位--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中的應(yīng)用
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">現(xiàn)在給出一種簡(jiǎn)單的辦法(其他的一些利用錨點(diǎn)等辦法都比較復(fù)雜)
private void Scroll(int index)
{
string s="<script>function window.onload(){document.all('"+this.DataGrid1.ClientID+"').rows["+index+"].scrollIntoView();}</script>";
Page.RegisterStartupScript("",s);
}寫(xiě)了一個(gè)方法,其中DataGrid1換成自己的DataGrid的ID,這個(gè)方法傳遞進(jìn)去的參數(shù)就是行號(hào),也就是e.Item.ItemIndex。
比如在編輯操作的時(shí)候會(huì)寫(xiě)this.DataGrid1.EditItemIndex=e.Item.ItemIndex;
在此語(yǔ)句的以前加入Scroll(e.Item.ItemIndex);就可以了
同樣在更新操作的時(shí)候?qū)憺镾croll(e.Item.ItemIndex);this.DataGrid1.EditItemIndex=-1;綁定;
相關(guān)文章
ASP.NET MVC制作404跳轉(zhuǎn)實(shí)例(非302和200)
本篇文章主要介紹了ASP.NET MVC制作404跳轉(zhuǎn)實(shí)例(非302和200) ,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-04-04
把a(bǔ)spx頁(yè)面?zhèn)窝b成靜態(tài)html格式的實(shí)現(xiàn)代碼
把a(bǔ)spx頁(yè)面?zhèn)窝b成靜態(tài)html格式的實(shí)現(xiàn)代碼,主要是利于搜索引擎的收錄。2011-10-10
.Net Core中使用ref和Span<T>提高程序性能的實(shí)現(xiàn)代碼
這篇文章主要介紹了.Net Core中使用ref和Span<T>提高程序性能的簡(jiǎn)單實(shí)現(xiàn)代碼,需要的朋友可以參考下2017-05-05
Net5?WorkService?繼承?Quarzt?及?Net5處理文件上傳功能
這篇文章主要介紹了Net5?WorkService?繼承?Quarzt?以及?Net5處理文件上傳,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-02-02
.NET下為百度文本編輯器UEditor增加圖片刪除功能示例
今天下載了目前最新版1.2.5為版本看更新記錄,主要是對(duì)表格做個(gè)修改,我下載用上,上傳圖片的刪除功能給取消了,下面與大家分享下增加圖片刪除功能示例2013-05-05
.NET中TextBox控件設(shè)置ReadOnly=true后臺(tái)取不到值三種解決方法
當(dāng)TextBox設(shè)置了ReadOnly=true后要是在前臺(tái)為控件添加了值,后臺(tái)是取不到的,值為空,多么郁悶的一個(gè)問(wèn)題經(jīng)過(guò)嘗試,發(fā)現(xiàn)可以通過(guò)如下的方式解決這個(gè)問(wèn)題.感興趣的朋友可以了解下2013-02-02
ASP.NET網(wǎng)站管理系統(tǒng)退出 清除瀏覽器緩存,Session的代碼
管理系統(tǒng)退出登陸后,將網(wǎng)址重新輸入后還會(huì)看到用戶登陸后的界面,為了解決這個(gè)問(wèn)題,我采用了以下方法,需要的朋友可以參考下2012-05-05

