Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I stop a frame from automatically scrolling?

Status
Not open for further replies.

frameuser

Technical User
Jun 13, 2001
109
US
I use a particular application (Quadralay's e-Publisher Pro) to create HTML versions of our documentation guides. The output generated consists of two frames. A narrow frame on the left contains the contents of the guide, and a wide frame on the right contains the guide text.

The contents are set up much like the Bookmarks pane in PDF files where entries are indented based on the contents hierarchy.

Code:
Guide Title
   Chapter 1, Chapter Title
      Heading 1
      Heading 2
   Chapter 2, Chapter Title
      Heading 1
      Heading 2

When I click on one of the indented contents headings, the contents pane automatically scrolls right so that the first character of the heading is at the very left side of the pane. As a result, you can no longer view the entire text of entries that are not indented that far.

Code:
Title
pter 1, Chapter Title
Heading 1
Heading 2
pter 2, Chapter Title
Heading 1
Heading 2

I assume that there's a JavaScript somewhere that's causing this behavior. But this application generates dozens of JS files, and I can't determine where the problem is, especially since I don't know squat about JavaScript. :)

I did find one JS file that contains ClearScrollPosition, SaveScrollPosition, and RestoreScrollPosition, but I don't know what to look for in those functions. I'm not even sure that these are for the contents pane and not for the text pane.

I know this is not very much information, but does anyone have any suggestions as to what I should look for? Or what information I need to include to help you help me?

Rick Henkel
 
This is completely stabbing in the dark if you're not gonna post any code, but you could search for a scrollLeft attribute being set on the frame. This is just one of the many ways to do it though. There's also the scrollIntoView command. They could also be referencing an anchor which would jump to that spot in the page.

This doesn't give you a lot to go on, but given the lack of detail you posted above it's about as close as I can get.

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
Thanks, kaht. Like I said, I wasn't sure what to include. The SaveScrollPosition that I mentioned includes some scrollLeft statements.


Code:
function  WWHPanels_SaveScrollPosition()
{
  var  PanelEntry;
  var  PanelObject;
  var  VarPanelViewFrame;


  if ( ! this.mbLoading)
  {
    // Access panel object
    //
    PanelEntry  = this.fGetCurrentPanelEntry();
    PanelObject = this.fGetCurrentPanelObject();
    if (PanelObject.mbPanelInitialized)
    {
      VarPanelViewFrame = eval(WWHFrame.WWHHelp.fGetFrameReference("WWHPanelViewFrame"));

      if ((WWHFrame.WWHBrowser.mBrowser == 1) ||  // Shorthand for Netscape
          (WWHFrame.WWHBrowser.mBrowser == 3) ||  // Shorthand for iCab
          (WWHFrame.WWHBrowser.mBrowser == 4) ||  // Shorthand for Netscape 6.0 (Mozilla)
          (WWHFrame.WWHBrowser.mBrowser == 5))    // Shorthand for Safari
      {
        PanelEntry.mScrollPosition[0] = VarPanelViewFrame.window.pageXOffset;
        PanelEntry.mScrollPosition[1] = VarPanelViewFrame.window.pageYOffset;
      }
      else if (WWHFrame.WWHBrowser.mBrowser == 2)  // Shorthand for IE
      {
        // Test required to avoid JavaScript error under IE5.5 on Windows
        //
        if (typeof(VarPanelViewFrame.document.body) == "undefined")
        {
          PanelEntry.mScrollPosition[0] = 0;
          PanelEntry.mScrollPosition[1] = 0;
        }
        else
        {
          if ((typeof(VarPanelViewFrame.document.documentElement) != "undefined") &&
              (typeof(VarPanelViewFrame.document.documentElement.scrollLeft) != "undefined") &&
              (typeof(VarPanelViewFrame.document.documentElement.scrollTop) != "undefined") &&
              ((VarPanelViewFrame.document.documentElement.scrollLeft != 0) ||
               (VarPanelViewFrame.document.documentElement.scrollTop != 0)))
          {
            PanelEntry.mScrollPosition[0] = VarPanelViewFrame.document.documentElement.scrollLeft;
            PanelEntry.mScrollPosition[1] = VarPanelViewFrame.document.documentElement.scrollTop;
          }
          else
          {
            PanelEntry.mScrollPosition[0] = VarPanelViewFrame.document.body.scrollLeft;
            PanelEntry.mScrollPosition[1] = VarPanelViewFrame.document.body.scrollTop;
          }
        }
      }
    }
  }
}

I'd tried commenting out certain portions of this section, but that only resulted in scripting errors or no change. Any suggestions?

Rick Henkel
 
Commenting out parts of the code will result in the scroll positions not ever getting set - this is likely not what you want. Instead, why not hard code the values to 0, that way no left scroll is applied? Try these changes and see if it works, and if it doesn't then the problem likely isn't with this function:
Code:
function  WWHPanels_SaveScrollPosition()
{
  var  PanelEntry;
  var  PanelObject;
  var  VarPanelViewFrame;


  if ( ! this.mbLoading)
  {
    // Access panel object
    //
    PanelEntry  = this.fGetCurrentPanelEntry();
    PanelObject = this.fGetCurrentPanelObject();
    if (PanelObject.mbPanelInitialized)
    {
      VarPanelViewFrame = eval(WWHFrame.WWHHelp.fGetFrameReference("WWHPanelViewFrame"));

      if ((WWHFrame.WWHBrowser.mBrowser == 1) ||  // Shorthand for Netscape
          (WWHFrame.WWHBrowser.mBrowser == 3) ||  // Shorthand for iCab
          (WWHFrame.WWHBrowser.mBrowser == 4) ||  // Shorthand for Netscape 6.0 (Mozilla)
          (WWHFrame.WWHBrowser.mBrowser == 5))    // Shorthand for Safari
      {
        PanelEntry.mScrollPosition[0] = VarPanelViewFrame.window.pageXOffset;
        PanelEntry.mScrollPosition[1] = VarPanelViewFrame.window.pageYOffset;
      }
      else if (WWHFrame.WWHBrowser.mBrowser == 2)  // Shorthand for IE
      {
        // Test required to avoid JavaScript error under IE5.5 on Windows
        //
        if (typeof(VarPanelViewFrame.document.body) == "undefined")
        {
          PanelEntry.mScrollPosition[0] = 0;
          PanelEntry.mScrollPosition[1] = 0;
        }
        else
        {
          if ((typeof(VarPanelViewFrame.document.documentElement) != "undefined") &&
              (typeof(VarPanelViewFrame.document.documentElement.scrollLeft) != "undefined") &&
              (typeof(VarPanelViewFrame.document.documentElement.scrollTop) != "undefined") &&
              ((VarPanelViewFrame.document.documentElement.scrollLeft != 0) ||
               (VarPanelViewFrame.document.documentElement.scrollTop != 0)))
          {
            [!]PanelEntry.mScrollPosition[0] = 0;[/!] [gray][i]//VarPanelViewFrame.document.documentElement.scrollLeft;[/i][/gray]
            PanelEntry.mScrollPosition[1] = VarPanelViewFrame.document.documentElement.scrollTop;
          }
          else
          {
            [!]PanelEntry.mScrollPosition[0] = 0;[/!] [gray][i]//VarPanelViewFrame.document.body.scrollLeft;[/i][/gray]
            PanelEntry.mScrollPosition[1] = VarPanelViewFrame.document.body.scrollTop;
          }
        }
      }
    }
  }
}

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top