473,799 Members | 2,940 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is there a way to remember a users last position in the document?

Suppose you got a really long page and you'd like to enable
the user (supposedly, there's only one but if it's not to
difficult we could extend that to any number) not to have
to scroll to the last position in the document he/she was
viewing but simply auto-jump him/her to it. Is that doable
at all using JS?

I guess it would be somewhere in the vicinity of:
- remember every scroll
- save the line number to the users HDD
- at next visit jump to the saved line

I have seen pages that "remember" me by cookies so i
guess that's a good start for the solution but the rest of
the issue i'd love to get some help with.

I've worked with Java and C++ for a few years so the
prorgamming issues are not a problem. However, i'm
still rather new to JS.

--

Vänligen
Konrad
---------------------------------------------------

Sleep - thing used by ineffective people
as a substitute for coffee

Ambition - a poor excuse for not having
enough sense to be lazy

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

Jul 23 '05
16 1620
> <quote>
Suppose you got a really long page and you'd like to enable
the user (supposedly, there's only one but if it's not to
difficult we could extend that to any number)...
</quote>

I took that to mean a certain degree of assurance of who those users
might be - and under what conditions this 'solution' might be
applied. In a general sense, you're quite right, HTML is not dtp
and any fix which relies on window configuration is not reliable.


Correct assumption! The "user" will most likely be me and
maybe (only maybe) a handfull of friends, none of which
is known to or expected to make any changes to the font
size, window position/size etc.

So, for all you know (and please go with that) you got my
drift exactly! Nevertheless, it's nice to know that there
are certain limitations to what can be achieved.

--

Vänligen
Konrad
---------------------------------------------------

Sleep - thing used by ineffective people
as a substitute for coffee

Ambition - a poor excuse for not having
enough sense to be lazy

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

Jul 23 '05 #11
Konrad Viltersten wrote:
<quote>
Suppose you got a really long page and you'd like to enable
the user (supposedly, there's only one but if it's not to
difficult we could extend that to any number)...
</quote>

I took that to mean a certain degree of assurance of who those users might be - and under what conditions this 'solution' might be
applied. In a general sense, you're quite right, HTML is not dtp
and any fix which relies on window configuration is not reliable.


Correct assumption! The "user" will most likely be me and
maybe (only maybe) a handfull of friends, none of which
is known to or expected to make any changes to the font
size, window position/size etc.

So, for all you know (and please go with that) you got my
drift exactly! Nevertheless, it's nice to know that there
are certain limitations to what can be achieved.

--

Vänligen
Konrad
---------------------------------------------------

Sleep - thing used by ineffective people
as a substitute for coffee

Ambition - a poor excuse for not having
enough sense to be lazy

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


Hey Konrad...the above works for me locally. If you can't get
window.onunload to run something is amiss. Might you be assigning it
somewhere else ? (it's the same as same as <body onunload=".."> btw)

Think about this while enjoying your girlfriend.

Jul 23 '05 #12
> Hey Konrad...the above works for me locally. If you can't get
window.onunload to run something is amiss. Might you be
assigning it somewhere else ? (it's the same as same as <body
onunload=".."> btw)

Well, it's really strange, since i get an event when loading...
Anyway, i have set up the minimal code that reproduces the
behavior. Does it work locally on you computer?

<html><head><sc ript type="text/javascript">
window.onload = function() {
alert ('The page has loaded successfully!') ;}
window.onunload = function() {
alert ('The page has started unloading!');}
</script></head>

<body><pre><scr ipt type="text/javascript">
var z = 0;
while (z++ < 200)
document.writel n(z);
</script></pre>
</body></html>

On my system only loading produces an alert...

Is that too browser depending? I have IE6.0
with SP2, as far as i can see.

--

Vänligen
Konrad
---------------------------------------------------

Sleep - thing used by ineffective people
as a substitute for coffee

Ambition - a poor excuse for not having
enough sense to be lazy

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

Jul 23 '05 #13
Konrad Viltersten wrote:
Hey Konrad...the above works for me locally. If you can't get
window.onunload to run something is amiss. Might you be
assigning it somewhere else ? (it's the same as same as <body
onunload=".."> btw)

Well, it's really strange, since i get an event when loading...
Anyway, i have set up the minimal code that reproduces the
behavior. Does it work locally on you computer?

<html><head><sc ript type="text/javascript">
window.onload = function() {
alert ('The page has loaded successfully!') ;}
window.onunload = function() {
alert ('The page has started unloading!');}
</script></head>

<body><pre><scr ipt type="text/javascript">
var z = 0;
while (z++ < 200)
document.writel n(z);
</script></pre>
</body></html>

On my system only loading produces an alert...

Is that too browser depending? I have IE6.0
with SP2, as far as i can see.

--

Vänligen
Konrad
---------------------------------------------------

Sleep - thing used by ineffective people
as a substitute for coffee

Ambition - a poor excuse for not having
enough sense to be lazy

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


This has been discussed here previously:

<URL:
http://groups-beta.google.com/group/...8a26e4f3adf256


Try window.onbefore unload...

Jul 23 '05 #14
>> Well, it's really strange, since i get an event when loading...
Anyway, i have set up the minimal code that reproduces the
behavior. Does it work locally on you computer?

window.onunload = function() {
alert ('The page has started unloading!');}
This has been discussed here previously:

http://groups-beta.google.com/group/...8a26e4f3adf256 Try window.onbefore unload...

Aha, there we go! Got it. It still doesn't work as the
computer doesn't scroll to the last position but from
here i think i'd like to fight it on my own for a while.
I'll make sure to get back bitching and whining if i
fail to do so, hehe.

Thanks!

--

Vänligen
Konrad
---------------------------------------------------

Sleep - thing used by ineffective people
as a substitute for coffee

Ambition - a poor excuse for not having
enough sense to be lazy

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

Jul 23 '05 #15
JRS: In article <11************ *********@g47g2 000cwa.googlegr oups.com>,
dated Fri, 13 May 2005 09:31:46, seen in news:comp.lang. javascript, RobB
<fe******@hotma il.com> posted :

var now = new Date();
now.setTime(now .getTime() + 365 * 24 * 60 * 60 * 1000);


var now = new Date();
now.setMonth(no w.getMonth() + 12);

is simpler, while avoiding the question of whether getFullYear and
setFullYear are supported.

var now = new Date(+new Date()+32e9);

gives a little over a year, and should be fast if the browser is smart
about object lifetimes.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #16

Richard Cornford wrote:
RobB wrote:
Konrad Viltersten wrote:
askMe wrote:
You could use anchors.
Do you mean
<snip>
(snip)

(snip)
Fred's solution was correct.


The problem with Fred's suggestion is that the degree to which a page
has previously been scrolled by a user will depend in part of the

layout and flow of the document.
Let alone if the user returns to the page from a different computer.
If his cookies just returned the user to an anchor, he won't need to
bother with screen dimensions, coordinates, scroll positions, type of
browser... and the list goes on.
So re-visiting the site with a browser window
of different dimensions will tend to invalidate the scroll offsets from previous visits.
Exactly!
And if the user has changed their default (or current)
font size between visits then previous scroll offsets will also no
longer be valid.
Another good point.
It may be that the real solution to this problem is the provision of
internal navigation on a page, so that the use can quickly get back to where they remember being.
Yes. Anchors and a click here to return link/button gets my vote,
especially since its for a small audience.
(snip)
Richard.


There are also lots of form scripts that return the user to the last
position, but they also rely on the user clicking a button to mark the
spot. He only needs to use hidden fields, getElementByID and focus to
go that route. Otherwise, he can just have the preset anchors that get
'saved' when the use is tired of reading and wants to mark a section or
paragraph to return to on next visit.

Browsers know what the coordinates are and use that data to return a
user to the same screen position when the back button is pressed. But,
as you pointed out, that deals only with the current window within the
current browser. Anchors don't care about the window or the browser
and neither do forms.

I would love to see a javascript that relates scroll position to
page/character position without user intervention. Never seen one.
Doubtful that I will.

http://www.askblax.com

Jul 23 '05 #17

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

Similar topics

0
1704
by: Sascha Folville | last post by:
Hi, I'm trying to transform a XML document to PDF using apache (xerces). I want different formatting for first and last page. My code looks like this: <fo:layout-master-set> <fo:simple-page-master master-name="first" ...> ... </fo:simple-page-master>
0
341
by: Betty Harvey | last post by:
The next meeting of the XML Users Group will be held on Wednesday, May 18, 2005 at the American Geophysical Union (AGU) at 2000 Florida Avenue, N.W., Washington, DC 20009-1277. The meeting starts at 7:00 p.m. and usually last approximately 2 hours. If attending the meeting by Metro, get off the Dupont Circle stop and walk north to Florida Avenue...turn right. There is no cost associated with attending but if you are planning on...
3
11265
by: jason | last post by:
I've got this javascript routine (i found on google - thank you) in an asp.net page that on page reload sets the cursor of a textbox to the last line. It works great! Using a similar concept, I have another application that uses a textbox like an editor window and has a save and other buttons. Problem is - when I save/post/reload, the textbox returns to cursor the top again. How can I preserve / save the exact cursor spot and return...
1
9870
by: Daniel | last post by:
hi, I had an asp:listbox, and everytime i click item inside, the bar automatically go to the top, is there any way to keep the scroll position? I turn on the smartNavigation, it still doesn't work. Thanks ahead.
3
14282
by: tldisbro | last post by:
Hello All, I am trying to use the returned value of the <fo:page-number> element/function in my <xsl:if> test condition. But am unsuccessful in doing so. Is it possible to use it in this fashion with a conversion or correct syntax? I would like to test the current page number and see if it is even or odd - and if it is odd I would like to perform additional steps. I would like to do something like this (assume all namespaces are set):...
4
7802
by: freefly_xml | last post by:
I want to test to see if I am on the last page of a document. In this example it is an invoice. I want to print a different table in REGION AFTER when I am on the last page. I have tried many variations, no luck yet. It seems like it should be an easy thing to do with xsl:choose. Any ideas? Here is one of my attempts. More detail of what the xml, xsl and pdf look like are here: http://www.bangboompow.com/xml/invoice/
2
3270
by: Kevin Burton | last post by:
I don't think I understand the last() function. I have a document that looks like: <Root> <Header>Some text</Header> <Message> <MessageID>1</MessageID> . . . . </Message>
0
1368
by: Betty Harvey | last post by:
NOTE: This is the last meeting of 2006!! The next meeting of the XML Users Group will be held on Wednesday, November 15, 2006 at the American Geophysical Union (AGU) at 2000 Florida Avenue, N.W., Washington, DC 20009-1277. The meeting starts at 7:00 p.m. and usually last approximately 2 hours. If attending the meeting by Metro, get off the Dupont Circle stop and walk north to Florida Avenue...turn right. There is no cost associated...
18
1449
by: Mel | last post by:
What is the best method to achieve this (I am relatively new to vb.net)? Should I use an ini file or the registry? Is there another option available in vb.net that is the preferred way? This application will reside on our network and more than one user could possibly run it so I don't think the local registry is the answer. Basically I just want to remember the options the last user chose on the form and then use those previously used...
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10251
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10225
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9072
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4139
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.