How to execute custom JavaScript in WebBrowser control? [duplicate]

ぐ巨炮叔叔 提交于 2019-11-27 15:09:25

问题


This question already has an answer here:

  • How to inject Javascript in WebBrowser control? 15 answers

I want to apply some styling commands to specific website inside WebBrowser control. The best way to do it is to invoke javascript (I want that style to be editable, with javascript it's easy). I know I can do it with webBrowser1.Navigate("javascript: alert('hi'); void(0);"); but maximum url length that webBrowser accepts is 502. How to execute longer scripts? Or maybe there is a way to append my CSS to web document?

P.S. I can't edit document's text property since it'll break scripts in this website and I need working copy but just slyled a bit.


回答1:


maybe WebBrowser0.Object.Document.parentWindow.Eval("alert('hello')");



来源:https://stackoverflow.com/questions/4517460/how-to-execute-custom-javascript-in-webbrowser-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!