473,385 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Save scroll position AND setFocus

JC
I'm sure you've all seen the save scroll position from 4 guys from
rolla which can be found here >
http://aspnet.4guysfromrolla.com/articles/111704-1.aspx
BUT
try to get that to work AND still be able to set the focus to a
control.

Here's the problem, when you set the focus by using the
registerstartupscript method the control gets the focus after the
scroll position has been set. When this happens the scroll position
gets set a second time but it sets the focused control at the bottom
of your page.
To test-
(you would need the scroll position code from the 4 guys site)
Build a page with a whole lot of <br>'s and in the middle put a
textbox and at the end put a button. In the button call

RegisterStartupScript("focus", "<script language=""JavaScript"">" &
vbCrLf & vbTab & "document.getElementById('TextBox3').focus();" &
vbCrLf & "<" & "/script>")

I want my page to stay scrolled to the bottom but it scrolls to the
point of the textbox.

Any ideas on how to fix this would be AMAZINGLY appreciated. I don't
need to use this code just need it to work.
No, smartnavigation will not work since you can not focus with that
either
(or if you can, let me know but I'd rather not use it)

contact me at the e-mail or at ujjc001@ on my gmail account but please
post here too for others to share.
Nov 19 '05 #1
1 8641
you need to set the focus after the scroll has happened. your focus scroll
changes the saved coordinates. there scroll happens at onload, and you need
to let the window scroll happen first. change their code to something like:

function sstchur_SmartScroller_Scroll()
{
var x = document.forms[formID].xCoordHolder.value;
var y = document.forms[formID].yCoordHolder.value;
document.forms[formID].focusHolder.value;
window.scrollTo(x, y);

window.setTimeout("document.forms[document.forms[formID].focusHolder.value].
focus()",10);
}

where you store the focus field name in focusHolder
-- bruce (sqlwork.com)
"JC" <uj*****@charter.net> wrote in message
news:b8**************************@posting.google.c om...
| I'm sure you've all seen the save scroll position from 4 guys from
| rolla which can be found here >
| http://aspnet.4guysfromrolla.com/articles/111704-1.aspx
| BUT
| try to get that to work AND still be able to set the focus to a
| control.
|
| Here's the problem, when you set the focus by using the
| registerstartupscript method the control gets the focus after the
| scroll position has been set. When this happens the scroll position
| gets set a second time but it sets the focused control at the bottom
| of your page.
| To test-
| (you would need the scroll position code from the 4 guys site)
| Build a page with a whole lot of <br>'s and in the middle put a
| textbox and at the end put a button. In the button call
|
| RegisterStartupScript("focus", "<script language=""JavaScript"">" &
| vbCrLf & vbTab & "document.getElementById('TextBox3').focus();" &
| vbCrLf & "<" & "/script>")
|
| I want my page to stay scrolled to the bottom but it scrolls to the
| point of the textbox.
|
| Any ideas on how to fix this would be AMAZINGLY appreciated. I don't
| need to use this code just need it to work.
| No, smartnavigation will not work since you can not focus with that
| either
| (or if you can, let me know but I'd rather not use it)
|
| contact me at the e-mail or at ujjc001@ on my gmail account but please
| post here too for others to share.
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Boniface Frederic | last post by:
Hello, I have frame displaying the last posted messages. I set <meta http-equiv="refresh" content="5"/> to automatically refresh the frame every 5s My problem is; if I scroll the frame to see...
2
by: GrantS | last post by:
I am trying to convert the VB.Net code example povided by http://authors.aspalliance.com/JimRoss/Articles/MaintainScrollPos.aspx into C# (ASP.Net)without success. No errors are thrown in the VB...
1
by: Ted | last post by:
I am trying to return the vertical scroll position of a rich textbox control using Access 2000. It seems to work for the horizontal scroll bar, but not the vertical. Code follows: Option...
4
by: 2D Rick | last post by:
In Access2003 and XP. My forms detail section hides behind the header when I scroll down to see controls off screen. This is similar to freezing a pane in Excel. I'd rather this did not happen...
0
by: Keithb | last post by:
The maintain scroll position on postback feature works as expected with my site running under localhost on the development machine. When the files are posted to an IIS 6.0 web server running on a...
5
by: RobertK | last post by:
I have a table that displays one row of images (thumbnails). When a user clicks on an image it opens up a bigger image below it. The row has about 20 cells. I have a <divtag which allows the user...
7
by: Lit | last post by:
Hi, How can I capture the vertical scroll bar position for a Listbox. I have a Listbox of 100 items + when I click on it I post back remove the item selected. After returning to the client...
1
by: wmbrae | last post by:
I trying to make a javascript document reader in 2 frames. The left frame displays the document, the right frame shows a list of document links. This is as far as I got ...
12
Frinavale
by: Frinavale | last post by:
I think I'm trying to do something impossible. I have a <div> element with a overflow style set to "scroll". In other words my <div> element allows the user to scroll the content within it. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.