Skip to main content Skip to footer

How To: Scroll to Last Page of AR WebViewer on Page Load

ActiveReports 6.0 has been quite popular due to its ability to display the output in various formats. With the Professional Edition license, you can use the WebViewer control to quickly display reports in any of four view types: HtmlViewer, RawHtml, AcrobatReader, or FlashViewer. In this blog article, I describe a small javascript handling technique to scroll the WebViewer control to the last page of the report when the Report loads in HTML view. The implementation concept is based on setting the last page index in the text area of the Navigation bar and then make a forced callback on the WebViewer control. It also uses a hidden field to keep track of the initial loading status for the WebViewer. The following code snippet shows the implementation.

<script type="text/javascript" language="javascript">// <![CDATA[  
        var start = true;  
        window.onload = function () {  

            var hdField = document.getElementById("HiddenField1");  

            if (hdField.value == "true") {  

                var pageField = document.getElementById("WebViewer1_txtPage");  

                if (pageField != null) {  
                    pageField.value = 128;  
                    hdField.value = "false";  
                    __doPostBack('WebViewer1', 'arvPageJump');  

// ]]></script></pre>  
<form id="form1">  

The above code snippet scrolls the WebViewer to the last page. However, using the above concept, you can tweak this to implement scrolling to any page. Refer the attached sample for complete implementation. Download Sample


comments powered by Disqus