object.scrollIntoView( [bAlignToTop])
Parameters
bAlignToTop | Optional. Boolean that specifies one of the following values:
|
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
|
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. |
2、定位指定DataGrid列
<div style="BORDER:0px;PADDING:0px;MARGIN:0px;OVERFLOW:scroll;WIDTH:600px;HEIGHT:200px" align="center">
現(xià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);
}
寫了一個(gè)方法,其中DataGrid1換成自己的DataGrid的ID,這個(gè)方法傳遞進(jìn)去的參數(shù)就是行號(hào),也就是e.Item.ItemIndex。
比如在編輯操作的時(shí)候會(huì)寫this.DataGrid1.EditItemIndex=e.Item.ItemIndex;
在此語句的以前加入Scroll(e.Item.ItemIndex);就可以了
同樣在更新操作的時(shí)候?qū)憺镾croll(e.Item.ItemIndex);this.DataGrid1.EditItemIndex=-1;綁定;
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com