如何在C#中使用jscript文件 [英] how to use jscript file in c#
本文介绍了如何在C#中使用jscript文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
不,您不能使用,javascript是基于文档对象模型的客户端脚本引擎浏览器中的(DOM)元素.您最好选择LINQ for .net,因为这样可以为Windows窗体提供类似于DOM的查询语法.实际上,您随后可以查询任何.Net类/对象.
参考链接:-我可以在C#.Net Windows窗体中使用javascript吗? [ 101个Visual C#的LINQ示例 [ http://jurassic.codeplex.com/ [ ^ ]
http://javascriptdotnet.codeplex.com/ [ ^ ]
您不能直接在winform上使用JScript.
但是网络浏览器控件的 InvokeScript 方法将支持您运行脚本.
检查以下代码
webBrowser1.DocumentText = @" ; webBrowser1.Document.InvokeScript(" );
看看下面的" JScript .NET "链接.
http://msdn.microsoft.com/en-us/library/aa289164%28v = vs.71%29.aspx
http://www.15seconds.com/issue/001012.htm
但是考虑到跨浏览器的兼容性,我总是更喜欢JavaScript而不是JScript.
hi
in desktop application how to use a jscript file in c#?
解决方案
No, you can''t use, javascript is a client scripting engine based on the Document Object Model (DOM) elements within a browser. Its better for you to should opt LINQ for .net as this provides a DOM like query syntax for your windows forms. In fact, you can then query any .Net classes / objects.
Reference Link :- Can i use javascript in C#.Net Windows Form?[^]
you can write/use an existing framework that handles this for you, and write some bindings to your UI or something.
More Reference :- 101 LINQ Samples for Visual C#[^]
http://jurassic.codeplex.com/[^]
http://javascriptdotnet.codeplex.com/[^]
You can not use JScript directly on winform.
but web browser control''s InvokeScript method will support you to run your scripting.
check the following code
webBrowser1.DocumentText =@"<html> <head> <script type='text/javascript'> function CallMe() { alert('test'); } </script> </head> <body></body></html>"; webBrowser1.Document.InvokeScript("CallMe");
Have a look at below links for "JScript .NET".
http://msdn.microsoft.com/en-us/library/aa289164%28v=vs.71%29.aspx
http://www.15seconds.com/issue/001012.htm
However I would always prefer JavaScript over JScript considering Cross Browser Compatibility.
这篇关于如何在C#中使用jscript文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文