Welcome Guest Search | Active Topics | Log In | Register

XHTML 1.0 Strict Compliance Options · View
encutz
#1 Posted : Tuesday, June 26, 2007 11:54:58 PM

Rank: YAF Forumling


Joined: 11/3/2006
Posts: 1
There is a problem with the SmartScroller JS code in Internet Explorer when used in standards compliance mode.

Basically you end up with a 'xxxxx.scrollLeft' is undefined error because of the way the hidden input box is referenced.

Modifying the .OnInit() function in SmartScroller.cs fixes the problem:

Code:

        protected override void OnInit(EventArgs e)
        {            
            string tFormID = "Form";

            if (Page.Parent != null)
                m_theForm = GetServerForm(Page.Parent.Controls);
            else
                m_theForm = GetServerForm(Page.Controls);

            if (m_theForm != null && m_theForm.ClientID != null)
            {
                tFormID = m_theForm.ClientID;
            }
                                        
            hidScrollLeft.ID = "scrollLeft";
            hidScrollTop.ID = "scrollTop";
    
            this.Controls.Add(hidScrollLeft);
            this.Controls.Add(hidScrollTop);                        
    
            string scriptString = @"
<!-- yaf.controls.SmartScroller ASP.NET Generated Code -->
<script language = ""javascript"">
<!--

  function yaf_SmartScroller_GetCoords()
  {
    var scrollX, scrollY;
    if (document.all)
    {
      if (!document.documentElement.scrollLeft)
        scrollX = document.body.scrollLeft;
      else
        scrollX = document.documentElement.scrollLeft;

      if (!document.documentElement.scrollTop)
        scrollY = document.body.scrollTop;
      else
        scrollY = document.documentElement.scrollTop;
    }
    else
    {
      scrollX = window.pageXOffset;
      scrollY = window.pageYOffset;
    }
    document.getElementById('" + hidScrollLeft.ClientID + @"').value = scrollX;
    document.getElementById('" + hidScrollTop.ClientID + @"').value = scrollY;
  }

  function yaf_SmartScroller_Scroll()
  {
    var x = document.getElementById('" + hidScrollLeft.ClientID + @"').value;
    var y = document.getElementById('" + hidScrollTop.ClientID + @"').value;
        if (x || y) window.scrollTo(x, y);
        if (oldOnLoad != null) oldOnLoad();
  }
    
    var oldOnLoad = window.onload;
 
  window.onload = yaf_SmartScroller_Scroll;
  window.onscroll = yaf_SmartScroller_GetCoords;
  window.onclick = yaf_SmartScroller_GetCoords;
  window.onkeypress = yaf_SmartScroller_GetCoords;
// -->
</script>
<!-- End yaf.controls.SmartScroller ASP.NET Generated Code -->";

    
            Page.ClientScript.RegisterStartupScript(Page.GetType(),"SmartScroller", scriptString);
        }


Please note that I have removed the yaf_getForm() JS function because there is no need for it.
CodeJunky2008
#2 Posted : Thursday, July 31, 2008 3:07:22 PM
Rank: Member


Joined: 4/24/2008
Posts: 27
Location: East Sussex UK
Great, thanks for the fix really appreciated Smile
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAFPro Theme Created by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.3 RC2 | YAF © 2003-2008, Yet Another Forum.NET
This page was generated in 0.057 seconds.

SourceForge.net Logo Powered by ASP.NET v2.0 411ASP.NET