我有以下的JavaScript code作为字符串:
I have the following JavaScript code as a string literal:
var $Page = new function()
{
var _url= 'http://www.some.url.com';
this.Download = function()
{
window.location = _url;
}
}
有没有办法,我能得到的 _url
变量从我的C#code中的价值?一个开源库吧?我这样做是使用普通的防爆pression,但我希望有更优雅的方式。
Is there a way I could get the value of the _url
variable from my C# code? An open source library perhaps? I did this using a Regular Expression, but I was hoping for a more elegant way.
您应该看看开源的Javascript .NET(的 HTTP://javascriptdotnet.$c$cplex.com/在codePLEX )
You should take a look at the open-source Javascript .NET (http://javascriptdotnet.codeplex.com/) on Codeplex.
的code此示例应该帮助你:
This sample of code should help you:
Javascript context = new JavascriptContext();
context.Run("var _url= 'http://www.some.url.com';") // You put your javascript in the function run
String url = (String)context.GetParameter("_url"); // You get your url from javascript
就是这样。
上一篇:什么是从FileSystemWatcher的错误中恢复的最佳做法是什么?是从、做法、错误、FileSystemWatcher
下一篇:如何映射UINT在NHibernate的与SQL Server 2005NHibernate、UINT、SQL、Server