Inject/serve custom CSS in WP8 WebBrowser Control

2019-08-25 05:34发布

问题:

Possible Duplicate:
How to inject Javascript in the WP7 WebBrowser control?

I have a WebBrowser control in my MainPage.xaml serving an external web page.

<phone:WebBrowser 
    Name="TravelPlanner" 
    Source="http://URL-HERE.com" 
    IsScriptEnabled="True"/>

Is it possible for me to somehow inject or serve my own CSS (or JavaScript for that matter)?

回答1:

Yes. By invoking WebBrowser.InvokeScript after WebBrowser.LoadCompleted you can execute arbitrary javascript code in a webbrowser control. Web apps can then use WebBrowser.ScriptNotify to talk back to C#.

See more @ How to inject Javascript in the WP7 WebBrowser control?