是否有办法在webbrowser控件的iframe中获取网页的跨域?
|
我一直在使用.NET WebBrowser控件进行搜索,以至少了解iframe(具有跨域)在网页中的域。
我正在使用.NET 2.0 Visual Studio 2005 C#
例如在webbrowser控件中,它具有带有iframe且具有不同域的网页。
我想获取值“ www.google.com”
http://localhost/index.html
<html>
<head></head>
<body>
<iframe src=\"http://www.google.com/foobar\"></iframe>
</body>
</html>
根据MSDN,由于跨域脚本,我试图获取域并获得ѭ1。
HtmlWindowCollection frames = webBrowser1.Document.Window.Frames;
if (frames.Count > 0)
{
for (int i = 0, j = frames.Count; i < j; i++)
{
//if the iframe in the page has different domain
if (frames[i].Document.Domain != this.webBrowser1.Document.Domain)
{
MessageBox.Show(\"iframe has different domain\");
}
}
}
但是看起来我什至无法访问该域。
我也尝试过Urlframes[i].Url
,但还是一样。
这是否意味着除了iframe之外,我实际上无法从iframe获得任何信息?有没有一种方法可以检测iframe是否具有其他域而不会引发异常?
没有找到相关结果
已邀请:
1 个回复
艰管垮淮