1

I am working on a project where I need to display a map with the user's current location on a Bing Maps (desktop application). I used an HTML document to get the coordinates and was able to display it in a WebBrowser control. Now I need access to the latitude and longitude values. I tried using Alex's approach in this question (his 2nd answer) but it only works if we are using web forms (WebBrowser.Document.GetElementbyId). Is there any way to get the values using the WebBrowser control in System.Windows.Controls namespace?

1
  • Not sure if I correctly understand your question (as you haven't linked any other question and answer). But if it's just about parsing HTML in a .Net application, Html Agility Pack may help a lot. Commented Sep 18, 2013 at 7:41

1 Answer 1

3

You can use WebBrowser.InvokeScript and eval to execute any JavaScript code inside the loaded page's namespace and get the result, e.g:

dynamic result = webBrowser.InvokeScript("eval", 
    new object[] { "{x: 0, y: 0, url: document.URL}" });
MessageBox.Show(result.url.ToString());
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.