Question

First question but I really am in a jam.

I have a webpage render which is working perfectly. However, I need to be able to control the initial display position (almost like a href #anchors in HTML) but without any access to the site content.

From as far as i can see i have no access to the scrollBars other than the bool to enable / disable..

Is there anything i can do to even force a scroll down of 20% for example, and then I can create a form to adjust later on.

Any assistance would be HUGELY appreciated although from what I have researched it seems unlikely.

I have the regular windows WebBrowser Render

private System.Windows.Forms.WebBrowser m_webBrowser;

Thanks !

--This is for c# standalone application.. Not WebBased.

Was it helpful?

Solution

Have you tried using jquery?

I personally use the animate method from jquery to scroll to certain elemnts in my webpage.

Example:

 $('html, body').animate({scrollTop: $('#the-element-you-want-to-scroll-to).offset().top}, 1000);

PS: For the last parameter you can control the time it will use to scroll to destination, that offering you a nice effect.(in milliseconds)

OTHER TIPS

I managed to resolve it using a strange method..

I basically injected some javascript into the rendered HTML manually.. Then the rest was easy.

i used something like this :

            string updatedSource = WebBrowser.DocumentText.Replace("Google", "Foogle");
            string extraSource =
            "<html><body>Script goes here <br/>" +
            "<div><p>BLA BLA BLA</p></div></body></html>";


            WebBrowser.DocumentText = extraSource + updatedSource;

            WebBrowser.Update(); 

Maybe it will help someone.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top