1

I have an app that displays pages from a website in a WebBrowser control. I want to add a "position:fixed" to the <header>, either through an inline style or an external stylesheet saved in my app's resources. Is this possible?

miguelarcilla
  • 1,426
  • 1
  • 20
  • 38

1 Answers1

1

It is possible, although I'm not sure if for online 3rd party pages as well - from your code you can invoke any JavaScript method using this method:

webBrowser.IsScriptEnabled = true; // make sure this property is set on your WebBrowser
webBrowser.InvokeScript(methodName, listOfParameters);

you can either have some target JavaScript method in web page code to be invoked, or you can directly invoke any code using the JavaScript "eval" method like this:

webBrowser.InvokeScript("eval", new[] { "document.body.style.zoom=\"80%\"" }

That's the basic idea, how to change your page programatically from C#, I won't go here into details here how to change CSS values using JavaScript.

Martin Suchan
  • 10,600
  • 3
  • 36
  • 66