Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsClientAPIClientAPIUsing the ScrollTop property?Using the ScrollTop property?
Previous
 
Next
New Post
5/23/2006 3:57 PM
 

I'd like to restore my user's scroll position automatically when they postback in a module's edit view. I see that default.aspx already has support for a ScrollTop hidden field and there is a bunch of javascript in dnn.dom.positioning.js and js\dnncore.js that seem to handle the scrollTop manipulations I need.

I think DNN will automatically resotre my scroll position if the ScrollTop hidden field is set. Can someone give me some advice on how and when to set the ScrollTop hidden field?


WildVoice.com Michael Levy - Are you ready to be heard? WildVoice.com
 
New Post
5/23/2006 5:40 PM
 

So, I learned a bit. Someone please tell me if this is correct.

DNN already preserves your scroll position on postback. However it appears to me that this only works in Firefox and Opera. I can't seem to get it to work in IE 6.  Is that true? Is there a way to get this to work in IE and I'm just missing it?

 

 

FYI, preserving scroll position on postback is already built in to Default.aspx and js/dnncore.js.


Default.aspx has hidden field to store scroll position:
 <INPUT ID="ScrollTop" runat="server" NAME="ScrollTop" TYPE="hidden">
 
Default.aspx registers  ONSCROLL event handler as:
  ONSCROLL="__dnn_bodyscroll()"
 
in js\dnncore.js

 function __dnn_bodyscroll()
 {
  var oF=document.forms[0]; 
  if (__dnn_ClientAPIEnabled() && __dnn_m_bPageLoaded)
   oF.ScrollTop.value=dnn.dom.getByTagName("body")[0].scrollTop;
 }


This function in the onscroll event, if the client API is enabled and the page load has completed, saves the
ScrollTop value in the Form hidden field called ScrollTop. On a Postback this value will be submitted.


In Default.aspx.vb, in the page_load, if the ScrollTop hidden field has a value, DNN regsiters an Onload event handlers to call the javascript function __dnn_setScrollTop(). This function finds the ScrollTop saved value from the Hidden field then sets the Body's scrolltop to the saved value:

function __dnn_setScrollTop(iTop)
{
 if (__dnn_ClientAPIEnabled())
 {
  if (iTop == null)
   iTop = document.forms[0].ScrollTop.value;
 
  var sID = dnn.getVar('ScrollToControl');
  if (sID != null && sID.length > 0)
  {
   var oCtl = dnn.dom.getById(sID);
   if (oCtl != null)
   {
    iTop = dnn.dom.positioning.elementTop(oCtl);
    dnn.setVar('ScrollToControl', '');
   }
  }
  dnn.dom.getByTagName("body")[0].scrollTop = iTop;
 }
}


 


WildVoice.com Michael Levy - Are you ready to be heard? WildVoice.com
 
New Post
5/23/2006 5:54 PM
 

I was going to say it should already be doing this, as you seem to have discovered.  What I am confused about is when you say it is not working with IE.  I tested it by placing a login control on a page, scrolling the page, then login with an invalid username and password.  The scroll position is remembered in every browser I try...

What is the scenerio you are seeing that is not working?


 
New Post
5/23/2006 10:59 PM
 

In Default.aspx we had changed the doctype. In order to get some Javascript and CSS features working in our modules we needed to specify a doctype. If we went to an XHtml doctype, solpart menu gave us some trouble. So we stayed with Html 4.0 Transitional, but explicitly specifed the DTD.

So, the original Doctype in default.aspx is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

We changed this to:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

That seems to be the single change that breaks the scroll position feature in IE 6. (It works fine in Firefox and Opera). We are exploring further, but if anyone has any suggestions they are appreciated.<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.Common.Controls" Assembly="DotNetNuke" %>


WildVoice.com Michael Levy - Are you ready to be heard? WildVoice.com
 
New Post
5/24/2006 8:58 AM
 

Here is some more info - http://www.sitepoint.com/article/javascript-from-scratch/6

When we specified the DTD that forced IE out of Quirks mode. I think Cross Browser support of scroll position out of quirks mode requires more browser specific code. Specifically,  I don't think the body onscroll event declared in Default.aspx works in IE 6 when it is out of quirks mode.

This article says:

   the properties used by each browser are shown here for reference:

  • window.pageYOffset is used by Firefox and other Mozilla browsers, Safari, Konqueror, and Opera.
  • document.documentElement.scrollTop is used by IE 6 in standards-compliant mode.
  • document.body.scrollTop is used by IE 5, and IE 6 in "Quirks" mode.

WildVoice.com Michael Levy - Are you ready to be heard? WildVoice.com
 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsClientAPIClientAPIUsing the ScrollTop property?Using the ScrollTop property?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out