本文介绍了任何解决方法,以获得一个iFrame文本在web浏览器的另一个域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可能首先会想到是因为XSS限制不可能的。但我想从承载 web浏览器的应用程序,而不是从一个网站的JavaScript代码访问这些内容。

You will probably first think is not possible because of XSS restrictions. But I'm trying to access this content from an application that hosts a WebBrowser, not from javascript code in a site.

我的理解是不可能的,通过非哈克手段来使用JavaScript访问这些内容,因为这将是一个很大的安全问题应该是不可能的。但它是没有意义的具有应用此限制承载 web浏览器。如果我想我的钢铁应用程序用户的Facebook信息,我可以做一个导航(facebook.com),做我想做的事情在里面。这是承载 web浏览器,而不是网页的应用程序。

I understand is not possible and should not be possible via non hacky means to access this content from javascript because this would be a big security issue. But it makes no sense to have this restriction from an application that hosts a WebBrowser. If I'd like to steel my application user's Facebook information, I could just do a Navigate("facebook.com") and do whatever I want in it. This is an application that hosts a WebBrowser, not a webpage.

另外,如果你用谷歌浏览器去包含一个iFrame其源是在另一个领域,然后右键单击它的内容,然后单击检查元素任何网页,它会告诉你的内容。更简单,如果你导航到包含另一个域的iFrame任何网页,你会查看的内容。如果你能看到它在 web浏览器,那么你应该能够通过编程访问它,因为它必须是某处在内存中。

Also, if you go with Google Chrome to any webpage that contains an iFrame whose source is in another domain and right click its content and click Inspect Element, it will show you the content. Even simpler, if you navigate to any webpage that contains an iFrame in another domain, you will see its content. If you can see it on the WebBrowser, then you should be able to access it programmatically, because it have to be somewhere in the memory.

有什么办法,而不是从DOM对象,因为他们似乎是基于相同的发动机,如JavaScript,因此通过XSS限制的限制,但一些低级别对象,如 MSHTML SHDOCVW ,访问此文字?

Is there any way, not from the DOM objects because they seem to be based on the same engine as javascript and therefore restricted by XSS restrictions, but from some more low level objects such as MSHTML or SHDocVw, to access this text?

推荐答案

这能对您有用?

foreach (HtmlElement elm in webBrowser1.Document.GetElementsByTagName("iframe"))
{
     string src = elm.GetAttribute("src");
     if (src != null && src != "")
     {
          string content = new System.Net.WebClient().DownloadString(src); //or using HttpWebRequest
          MessageBox.Show(content);
     }
}

这篇关于任何解决方法,以获得一个iFrame文本在web浏览器的另一个域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 15:22