SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist NokX's Avatar
    Join Date
    Feb 2003
    Location
    Knoxville, TN
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Repositioning the Scrollbars

    in the parent window, i have some objects that will release a pop-up window. in the pop-up window you can make various changes that will affect the database. to see those changes in the parent window, i need to refresh...right?

    well, when i refresh...if you're working at the bottom of the page it pops the scrollbars all the way back up to the top. is there a way to reposition the scrollbars without the use of anchors?

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You didn't mention which server-side scripting language you're using so I'll make this generic. When you refresh the page, do a check (in your server code) for a form element named "Scroll_Value". For example, in JSP:
    Code:
    if (request.getParameter("Scroll_Value") != null)
    If the field exists, echo/Response.write/print this into the outgoing file:
    Code:
    onload = function()
    {
    	window.scrollTo(0, value of "Scroll_Value");
    }
    This goes in the page:
    Code:
    function passScrollValue(oForm)
    {
    	if (typeof document.createElement != 'undefined')
    	{
    		var scrollValue = null;
    		if (typeof document.body != 'undefined' && typeof document.body.scrollTop  != 'undefined')
    			scrollValue = document.body.scrollTop;
    		else if (typeof window.PageYOffset != 'undefined')
    			scrollValue = window.PageYOffset;
    
    		if (scrollValue)
    		{
    			var input = document.createElement('input');
    			input.setAttribute('type', 'hidden');
    			input.setAttribute('name', 'Scroll_Value');
    			input.setAttribute('value', scrollValue);
    			oForm.appendChild(input);
    		}
    	}
    }
    You can call it like so: <form........onsubmit="passScrollValue(this)">
    ...or from any widget used to reload the form.
    ::: certified wild guess :::

  3. #3
    SitePoint Evangelist NokX's Avatar
    Join Date
    Feb 2003
    Location
    Knoxville, TN
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'm using coldfusion...

    i've used the method you've suggested before, i was just hoping that there was a simple "function" like window.opener.location.reload(); except that doesn't replace the scroll bars back to where they were.

    kinda like, if you hit refresh (F5)...it will rebuild the page, but it will also replace the scroll bars to where they were.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •