开发者

How do I invoke a Javascript that does not have a name using C#

I would like to invoke a Javascript function on a web page that does not have a f开发者_如何学JAVAunction name. Using C#, I would normally use Webbrowser.Document.InvokeScript("ScriptName"). In this instance however, there is only a type attribute. This is what it looks like:

<script type="text/javascript"> 
(function(){
    SOME CODE HERE;
})();
</script>


That is a self-invoking function.
It will run as soon as that statement is executed.

It is not possible to run it again without modifying the script.


As long as this closure does not export methods to the global namespace, you can't


Expose a Method.

<script type="text/javascript"> 
(function(){
    MyFunction = function() {
      SOME CODE HERE;
    }
})();
</script>


Webbrowser.Document.InvokeScript("MyFunction");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜