在C#控制台应用程序中呈现HTML/执行JavaScript [英] Render HTML/Execute JavaScript in C# Console Application
本文介绍了在C#控制台应用程序中呈现HTML/执行JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个这样的html页面:-
I am having an html page like this:-
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="http://......someFile.js"> </script>
<script>
function CallJs()
{
var decodedCookie = decodeURIComponent(document.cookie);
document.write(decodedCookie);
}
</script>
</head>
<body onload="CallJs();">
</body>
</html>
如果我在浏览器上执行此页面,则会得到所需的结果.但我想在不使用浏览器的情况下执行此页面中编写的JavaScript代码.我想在C#控制台应用程序上执行它.
If I execute this page on a browser I get the desired result. But I want to execute the JavaScript code written in this page without using a browser. I want to execute it on a C# console application.
有什么办法吗?
推荐答案
在这种情况下,您可以尝试使用msscriptcontrol.您可以检查以下线程:
You can try to use msscriptcontrol in this situation. You can check below thread:
我如何从VB.NET控制台应用程序调用外部JScript函数?
您还可以查看下面的文章,这可能对您有帮助.
You can also check the article below which may help you.
这篇关于在C#控制台应用程序中呈现HTML/执行JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文