如何点击一个按钮,定位到指定位置的一个div,不用我拉滚动条到下面看。

zzxap 2008-07-22 02:34:44
我在一个一面上有上中下3个div。点击搜索按钮,画面马上定位到页面下面的搜索输入框。
如何点击一个按钮,定位到指定位置的一个div,不用我拉滚动条到下面看。
div是用绝对定位的

<div id="d" style="BORDER-RIGHT: red 1px solid; BORDER-TOP: red 1px solid; Z-INDEX: 104; BACKGROUND: #cccc99; LEFT: 10px; BORDER-LEFT: red 1px solid; WIDTH: 736px; BORDER-BOTTOM: red 1px solid; POSITION: absolute; TOP: 4px; HEIGHT: 152px">
<P>     
<asp:label id="Label16" runat="server">廠ID:</asp:label><FONT face="新細明體"> </FONT><asp:textbox id="TextBox1" runat="server"></asp:textbox>   
</P>
<P><FONT face="新細明體">     </FONT>
<asp:label id="Label17" runat="server">倉位:從</asp:label><asp:textbox id="TextBox2" runat="server"></asp:textbox><asp:label id="Label1" runat="server">到</asp:label><asp:textbox id="TextBox3" runat="server"></asp:textbox><FONT face="新細明體">    
</FONT>
</P>
<P><FONT face="新細明體">    
<asp:label id="Label2" runat="server">成品/半成品編號:從</asp:label>     </FONT>
<asp:textbox id="TextBox4" runat="server"></asp:textbox><asp:label id="Label3" runat="server">到</asp:label><asp:textbox id="TextBox5" runat="server"></asp:textbox><FONT face="新細明體">   
</FONT>
</P>
<FONT face="新細明體">
<P>     
<asp:label id="Label5" runat="server">模具編號:從</asp:label><asp:textbox id="TextBox6" runat="server"></asp:textbox><asp:label id="Label4" runat="server">到</asp:label><asp:textbox id="TextBox7" runat="server"></asp:textbox>   </P>
<P>     
<asp:label id="Label6" runat="server">需求日期:從</asp:label><asp:textbox id="TextBox8" runat="server"></asp:textbox><asp:label id="Label7" runat="server">到</asp:label><asp:textbox id="TextBox9" runat="server"></asp:textbox>
   </FONT><asp:button id="searchall" runat="server" Width="86px" Text="多條件查詢"></asp:button>     
<asp:button id="Button2" runat="server" Text="返回"></asp:button></P></div>
...全文
543 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
nicholsky 2008-07-23
  • 打赏
  • 举报
回复
6楼的牛,竟然有这个scrollIntoView,不知兼容性通用性如何,一般我们都是用锚#,其它元素还可以用onfocus、select等类似的达到接近效果。
Hongfei_lu 2008-07-23
  • 打赏
  • 举报
回复
记录下你DIV为焦点是滚动条的位置,把按钮的onclick事件加入window.scroll(x,y)(x,y为位置)即可
lovewds2002 2008-07-23
  • 打赏
  • 举报
回复
锚点最简单方便吧.
zzxap 2008-07-22
  • 打赏
  • 举报
回复
多谢
  • 打赏
  • 举报
回复
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function showSearch(){
var oDiv=document.getElementById("div6");
oDiv.scrollIntoView();
}
</script>
</head>
<body>
<input type="button" value="Search" onclick="showSearch()"/>
<div id="div1" style="width:100px;height:20px;background-color:#999999;margin-top:100px;">1</div>
<div id="div2" style="width:100px;height:20px;background-color:#999999;margin-top:100px;">2</div>
<div id="div3" style="width:100px;height:20px;background-color:#999999;margin-top:100px;">3</div>
<div id="div4" style="width:100px;height:20px;background-color:#999999;margin-top:100px;">4</div>
<div id="div5" style="width:100px;height:20px;background-color:#999999;margin-top:100px;">5</div>
<div id="div6" style="width:100px;height:20px;background-color:#999999;margin-top:100px;">Search</div>
<div id="div7" style="width:100px;height:20px;background-color:#999999;margin-top:100px;">7</div>

<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</body>
</html>

zzxap 2008-07-22
  • 打赏
  • 举报
回复
c#怎樣實現
happy002 2008-07-22
  • 打赏
  • 举报
回复
$("#divid").foucs();
zzxap 2008-07-22
  • 打赏
  • 举报
回复
期待高手出現。。。
wtcsy 2008-07-22
  • 打赏
  • 举报
回复
命名锚记 不就可以吗?
<a href="#a">asd</a><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> <a name="a" id="a"></a><div>123</div><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
xiaoting924 2008-07-22
  • 打赏
  • 举报
回复
将按钮的click事件定位到要点击的div上不就可以达到目的了吗?

87,904

社区成员

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

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