•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 374,020 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,746 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 7995 | Replies: 1
![]() |
•
•
Join Date: Dec 2004
Posts: 457
Reputation:
Rep Power: 4
Solved Threads: 5
Hello guys,
can anyone offer guidance on how to implementthe following:
I have a JSP page that automatically refreshes every minute. However the page is fairly long and when the user moves the scrollbar down the page, and the minute is
up the JSP page is refreshed and the user is automatically taken back to the start of the page, not where they where before.
I've found many examples whilst googl'n the internet but none which have really worked.
I think I just need to get the X and Y co-ordinates of the vertical scroll bar... store them...refresh the page and load them back in
Not sure if this function would be any use when loading them back in:
Thankyou
can anyone offer guidance on how to implementthe following:
I have a JSP page that automatically refreshes every minute. However the page is fairly long and when the user moves the scrollbar down the page, and the minute is
up the JSP page is refreshed and the user is automatically taken back to the start of the page, not where they where before.
I've found many examples whilst googl'n the internet but none which have really worked.
I think I just need to get the X and Y co-ordinates of the vertical scroll bar... store them...refresh the page and load them back in
Not sure if this function would be any use when loading them back in:
window.scrollTo(X,Y);
Thankyou
You'll have to get the scroll offsets and sent it to the server with every refresh, or you can store it in a cookie.
Then when the refreshed window has loaded, scroll the window to the saved scroll offsets.
Heres how to get the scroll offsets:
ref: http://www.howtocreate.co.uk/tutoria.../browserwindow
To save stuff in cookies via javascript you can use;
ref: http://www.dustindiaz.com/top-ten-javascript/
Then when the refreshed window has loaded, scroll the window to the saved scroll offsets.
Heres how to get the scroll offsets:
function getScrollXY() {
var scrOfX = 0, scrOfY = 0;
if( typeof( window.pageYOffset ) == 'number' ) {
//Netscape compliant
scrOfY = window.pageYOffset;
scrOfX = window.pageXOffset;
} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
//DOM compliant
scrOfY = document.body.scrollTop;
scrOfX = document.body.scrollLeft;
} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
//IE6 standards compliant mode
scrOfY = document.documentElement.scrollTop;
scrOfX = document.documentElement.scrollLeft;
}
return [ scrOfX, scrOfY ];
}To save stuff in cookies via javascript you can use;
/**
* Get a cookie value
* @param string cookie name
*/
commonLib.prototype.getCookie = function( name ) {
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}
/**
* Set a cookie
* @param string cookie name
* @param string cookie value
* @param string cookie expiration counter in days
* @param string cookie path
* @param string cookie domain
* @param bool secure?
*/
commonLib.prototype.setCookie = function( name, value, expires, path, domain, secure ) {
var today = new Date();
today.setTime( today.getTime() );
if ( expires ) {
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );
document.cookie = name+"="+escape( value ) +
( ( expires ) ? ";expires="+expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
/**
* Remove a cookie
* @param string cookie name
* @param string cookie value
* @param string cookie path
* @param string cookie domain
*/
commonLib.prototype.deleteCookie = function( name, path, domain ) {
if ( getCookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
} www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
- Network Folder Refresh Problem (Windows NT / 2000 / XP / 2003)
- .net authentication / refresh problem (ASP.NET)
- IE6 & XPsp2 refresh problem (Web Browsers)
- IE Refresh problem, startnow.com causing problems (Web Browsers)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Submit or action button
- Next Thread: how to create floating menu


Linear Mode