0
Answer

Calling a Javascript function in the C# webBrowser control

bita hekmat

bita hekmat

9y
460
1
I've wrote this code and it's okay in Vs2008 (xp-sp3) but in Vs2010 (windows 7 ) it dosen't work
What do you think about this problem ? And how can i solve that?
 
I wanna get the phone number of  Html  source   this link :
http://tehran.divar.ir/v/%D9%BE%D8%B1%D8%A7%DB%8C%D8%AF-141-%D8%B3%D9%81%DB%8C%D8%AF-%D9%85%D8%AF%D9%84-%D8%B4%D9%87%D8%B1%DB%8C%D9%88%D8%B1-89/V9TAo4aLx/
 //**
private void button1_Click(object sender, EventArgs e)
{
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
HtmlElement H_EL = webBrowser1.Document.GetElementById("phone_field");
H_EL.GetElementsByTagName("A")[0].InvokeMember("click");


MessageBox.Show(H_EL.GetElementsByTagName("b").Count.ToString());

MessageBox.Show(H_EL.GetElementsByTagName("b")[0].InnerText);


}

private void button2_Click(object sender, EventArgs e)
{
webBrowser1.Document.InvokeScript("showContactInfo");


 //**
 
this is my problem
This phone number isn't in source HTML  source and show this when I click on java script
I do this with another solution ,when I click F12 in googlechrome and write this code in console after that show the phone number
//**
 
$('#phone_field a:first').trigger('click');
alert($('#phone_field b').text());
 
//**

How can I do like this in #c
__
before click javascript button
 
 
http://uploads.im/0l5WF.png
 
after click javascript button
 
http://uploads.im/k4oJ6.jpg