Also scroll to anchor ID

In your page code
  //----- GET OTHER URL ARGUMENTS -----
  $ScrollPageToAnchorId = $_GET['scroll_to_anchor'] ?? '';

  if ($ScrollPageToAnchorId !== '')
  {
    //SCROLL PAGE TO ANCHOR
    $HtmlOutput .= <<<_END
      <script>
        document.addEventListener("DOMContentLoaded", function(event) {
          document.getElementById('$ScrollPageToAnchorId').scrollIntoView(true);
        });
      </script>
_END;
  }
To trigger it
  //Redirect to same page to clear POST
  $RedirectToUrl = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);    //Get page without any url arguments
  $RedirectToUrl .= "?gid=$GroupId";
  $RedirectToUrl .= "&scroll_to_anchor=MyAnchorIdName";
  echo '<script>window.location.replace("' . $RedirectToUrl . '");</script>';
  return '';
USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through resources like this. We hope you find it helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support here. If you need help with a problem please use one of the many online forums.

Comments

Your email address will not be published. Required fields are marked *