如何在 IE 插件中获取子域中 IFrame 的页面源
我正在使用 C# 中的 BandObjects 制作 IE 插件。我正在让我的网络浏览器导航到一个页面,假设它是 example.com。在该页面中有一个 IFrame,其 src 是 sub.example.com。因此,IFrame 指向一个子域。我能够获取 IFrame 的 URL,但无法获取页面源,当我在浏览器中查看时,它就在那里,但通过代码我只能查看脚本,看不到数据。 我正在粘贴 IFrame:
<iframe height="40" src="http://sub.example.com/....php?style=web&ext=1305964161&hash=Ng1gwLG821-f" frameBorder="0" width="300" scrolling="no"></iframe>
当我通过 Visual Studio 查看此元素时,在 HTML 视图中,它会向我显示数据,即一封电子邮件,而文本视图会显示此数据。我如何获取 HTML 视图或说出此 Iframe 的页面源。 所以,总的来说,我想要这个 IFrame 中包含的数据,浏览器以某种方式执行它,但我如何用代码来做到这一点? 我访问了很多网站、论坛,但无法让它工作。
I am making an IE Addon using BandObjects in C#. I am making my web browser navigate to a page, suppose it's example.com. In that page there's an IFrame whose src is sub.example.com. So, IFrame points to a subdomain. I am able to fetch the URL of the IFrame, but unable to get the Page Source, when I view in the browser, it's there, but through code I can only view the script, no data.
I am pasting the IFrame:
<iframe height="40" src="http://sub.example.com/....php?style=web&ext=1305964161&hash=Ng1gwLG821-f" frameBorder="0" width="300" scrolling="no"></iframe>
When I view this element through visual studio, in HTML view, it shows me the data, that's an email, and Text View shows this. How do I get the HTML view or say the Page Source if this Iframe.
So, overall I want the data contained in this IFrame, the browser executes it some way, but how can I do it with code?
I have visited lot of sites, forums, but couldn't get it to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那么在活动的浏览器中,代码就是代码,没有办法在活动窗口中查看框架的源代码,除非框架足够大,可以右键单击并查看其自身的源代码。否则,您将坚持使用浏览器中呈现的内容作为源,而 iframe 则在某种程度上是无关紧要的。但是,将其视为您制作的附加组件,是否可以将 iframe 的 url 加载到某种隐藏窗口中,然后像活动页面一样获取代码?你可以在你的插件中的任何地方使用javascript吗?我知道这是一个愚蠢的问题,但我从未为浏览器构建过插件。
如果您可以使用 javascript,但是也许可以获取 iframe 名称/id/任何内容来识别它,然后在元素上使用innerHTML,您也许能够捕获源代码。
Well in the browser thats active the code is what the code is, theres no way of viewing the source of a frame within the active window unless of course the frame is large enough to right click on and view the source of itself. Otherwise your stuck with whats rendered in the browser as your source and the iframe per say is irrelevant in a matter of speaking. However seeing as its an add-on your making is it possible to load the url of the iframe up in a hidden window of sorts and then obtain the code that way as you would for the active page? Can you use javascript anywhere in your addon? I know thats a silly question but Ive never built an addon for a browser.
if you can use javascript however maybe something like getting the iframe name/id/whatever to identify it and then using innerHTML on the element you might be able to catch the source.