1

i have a Windows Forms application, which uses a Webbrowsercontrol to display a dynamically generated Htmlpage. Is there a possibility to interact with the jscode of the page? For example if i have have the following function:

<script type="text/javascript">
function ReturnValue()
{
var output;
output ='test';
return output;
}
</script> 

Would there be a possibility to receive "test" in my application (not trough url)?

4
  • 1
    Maybe something like InvokeScript could help? msdn.microsoft.com/en-us/library/… Just guessing, never done it. Commented Jul 25, 2013 at 13:32
  • Yes, that would be usefull if i wanted to execute a jsfunction from my application, but the function is called f.e. on the onclickevent of a button (so i dont have any authority when it occures) and i want the result. I dont want to call a fuction, a ionly want the result Commented Jul 25, 2013 at 13:36
  • 1
    Maybe make the variable you want have a bigger scope, and then write a method that returns it... then call that? Might be a better way, but that sounds like it would work. Commented Jul 25, 2013 at 13:37
  • 1
    Thanks... to simple to think about that. Tyvm Commented Jul 25, 2013 at 13:39

1 Answer 1

2

Yes it's possible using InvokeScript on the browser control; see this article for more information: http://www.codeproject.com/Tips/127356/Calling-JavaScript-function-from-WinForms-and-vice

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.