0
在我的C#應用程序的網頁的響應我得到了下面的代碼:獲取包含的JavaScript
private void button1_Click(object sender, EventArgs e)
{
string uri = urlTextBox.Text;
Uri myURL;
if (!Uri.TryCreate(uri, UriKind.Absolute, out myURL))
return;
WebRequest request = WebRequest.Create(myURL);
request.Method = "GET";
using (WebResponse response = request.GetResponse())
{
using (Stream stream = response.GetResponseStream())
{
using(StreamReader sr = new StreamReader(stream))
{
responseTextBox.Text = sr.ReadToEnd();
}
}
}
}
但是,當我按一下按鈕返回我下面的文字:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Login Timed Out</title>
<link rel=stylesheet type="text/css" href="../../shared/css/ilearn_base.css">
<script>
function redirectToTop(reloginLoc) {
if (opener != null && opener != self) {
opener.top.location = reloginLoc;
window.close();
}
else if (top != self) {
top.location = reloginLoc;
}
else {
location = reloginLoc;
}
}
</script>
<noscript>
Your browser does not support JavaScript. Please turn on JavaScript to use the features of this web page.
</noscript>
</head>
<body onLoad="redirectToTop('../../learner/jsp/relogin_site.jsp')">
</body>
</html>
我不明白爲什麼它說:「Your browser does not support JavaScript. Please turn on JavaScript to use the features of this web page.
」,因爲我在當前的瀏覽器和IE瀏覽器都激活了JavaScript。
在我的互聯網瀏覽器中,頁面看起來不同,執行腳本,我想了解如何在C#瀏覽器中激活JavaScript以獲得完整響應。
我懷疑你實際上是在尋找一個「模擬用戶代理」......像http://watin.org/ – corlettk