Reputation: 1456
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?
Upvotes: 1
Views: 621
Reputation: 10620
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.
Upvotes: 1