I want to open some websites which may contain javascript code for example google analytics or piwik. I think the using a webclient is the easiest way to visit websites but does the webclient run javascript code in the background automaticly or how could I get javascriptcode running by visiting a website in C#?
4 Answers
If you are looking for something with a UI interface, look at the WebBrowser Control.
If you need to just get the DOM or underlying elements of the DOM, I would suggest Watin. It is very mature and works well and its fast.
5 Comments
razoR
Does Watin run clientside code (javascript) from website automatic?
Icemanind
@razoR - yes. It does AJAX calls too
razoR
As I understand IE or FF needs to be installed and Watin just built a bridge for easy commands, am I wrong or did I need to configure anything before or does Watin contain IE? I'm not sure if each user of my app would have IE or Firefox installed.
Icemanind
It should only require that if you plan to install the plugins to be able to use Waitin directly from your browser. It shouldn't require a browser when using it programmically from C#.
Murtaza Munshi
Nice one. At least showed me a direction to work on.
in C# there is an Internet Explorer control. You can execute javascript code on a client PC by setting web URL link to this control. Internet Explorer control is a fully functional browser which executes all client code.
4 Comments
razoR
I think this is overloaded, I just need to visit pages and get javascript code runned (main goal are only analytic softwares). I don't need to get screenshots.
John Saunders
Actually, it's called the WebBrowser Control, and it's not part of C#. It's part of .NET.
klim
sorry, I wasn't correct. it is WebBrowser Control. and you don't need to render web page on your form, the control can be hidden.
klim
Unfortunately there is no any other ways how to run javascript code on client PC. Only client browser can execute all the code on client PC.
visibleproperty tofalseif you don't care about displaying any information.