转到某行

于尚 2006-04-17 11:40:27
<A href="#1">你们提供那些支援服务?</A>

......(很长的页面)

<TD vAlign="top" align="left"><A name="1">问:</A></TD>

这是一页里的代码,点击上边的连接可以显示到底下<A name="1">问:</A> 这个标记处,
我想问能不能通过脚本实现这个功能!!就是说,我需要点击上边的连接,在页面初始化时我写好一段脚本就可以显示到低下的标记处的内容,不需要再拖动滚动条!!!!
...全文
121 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
<script language="javascript" >
var a=document.createElement("A");
a.style.display="none";
a.href="#1"
document.body.appendChild(a);
a.click();
</script>
hbhbhbhbhb1021 2006-04-17
  • 打赏
  • 举报
回复
楼上已经说了,补充一点
name要符合标识符的要求,首字符不能用数字



可以用脚本实现滚动
<TD vAlign="top" align="left"><A name="a1">问:</A></TD>

document.getElementById("a1").scrollIntoView();
xxuu503 2006-04-17
  • 打赏
  • 举报
回复
控件.scrollIntoView

滚动到屏幕的最上端或者是最下端(如果在可视区之外)
xxuu503 2006-04-17
  • 打赏
  • 举报
回复

scrollIntoView Method Internet Development Index

--------------------------------------------------------------------------------

Causes the object to scroll into view, aligning it either at the top or bottom of the window.

Syntax

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.

SHOWExample

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

[ Object Name ]
Platform Version
Win16:
Win32:
Windows CE:
Unix:
Mac:
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.

于尚 2006-04-17
  • 打赏
  • 举报
回复
不能用脚本实现吗??
于尚 2006-04-17
  • 打赏
  • 举报
回复
我这个是在提交表单里边,要是重定向一个页面以前填写的值就没了啊!!
treeroot 2006-04-17
  • 打赏
  • 举报
回复
用锚
<a name="here"></a>

<a href="here">goto</a>
ybcola 2006-04-17
  • 打赏
  • 举报
回复
file.htm#1
ybcola 2006-04-17
  • 打赏
  • 举报
回复
访问的时候直接file.htm?#1
于尚 2006-04-17
  • 打赏
  • 举报
回复
xxuu503(我爱郭芙蓉!)
hbhbhbhbhb1021(天外水火(我要多努力))
谢谢
于尚 2006-04-17
  • 打赏
  • 举报
回复
好使,谢谢各位了。

87,997

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧