在 IE 中分叉或复制用户浏览器会话

发布于 2024-07-08 05:42:51 字数 748 浏览 7 评论 0原文

是否可以在 Internet Explorer 插件中分叉用户会话(或执行类似操作)?

我想处理用户单击工具栏中的按钮时所在的页面。 为了避免中断用户浏览,我想“复制”所有内容,以便可以在后台解析和处理页面。 处理过程可能涉及加载 Google 搜索结果链接的内容(如果按钮被点击的地方)等。

所以 - 我基本上想要的是模仿 Ctrl+N 但对用户隐藏窗口,这样他们就不会被打断。

如您所见,如果您在 http://www.snee.com/xml/crud/posttest.html" rel="nofollow noreferrer">http://www. snee.com/xml/crud/posttest.html 并按 Ctrl+N,发布的所有内容仍会出现在新窗口中,但不会出现将数据发布两次。

我正在考虑以某种方式复制 IWebBrowser2,但是:

  • 我不确定这是否可能(我在 MSDN 上找不到任何信息)
  • 我不知道它是否复制会话以及。

创建 IWebBrowser2 的新实例并简单地导航到当前 URL 并不是一个有效的解决方案,因为 POST 变量当然不会被保留。

Is it possible to fork a users session (or do something similar) in a Internet Explorer plugin?

I want to process the page the user is on when they click a button in the toolbar. To avoid interrupting the users browsing, I'd like to "copy" everything so I can parse and process the page in the background. The processing can involve things such as loading the content of the result links on a Google search, if that's where the button was clicked.

So - what I basically want is to imitate Ctrl+N but hide the window from the user, so they won't be interrupted.

As you can see, if you fill out and submit the form on http://www.snee.com/xml/crud/posttest.html and press Ctrl+N, everything posted will still appear in the new window, but it won't post the data twice.

I was thinking of somehow copying the IWebBrowser2, but:

  • I'm not sure if that's possible (I haven't been able to find any information on MSDN)
  • I don't know if it copies the sessions as well.

Creating a new instance of the IWebBrowser2 and simply navigating to the current URL isn't a valid solution as POST-variables of course doesn't get carried over.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

糖粟与秋泊 2024-07-15 05:42:51

BHO 或插件就可以了。
获取源代码的选项有很多,有点多。 选择你的姿势。
查找 IDocHostUIHandler 以改变行为。 IHTMLElementCollection 用于解析浏览器中的页面。
我目前能想到的最简单的事情是......

将当前内容保存到流中。 与获取/查看源代码相同。

// #include 
HRESULT SaveDocumenttoStream(IWebBrowser* pWebBrowser, 
                             IStream* pStream)
{
HRESULT hr;
IDispatch* pHtmlDoc = NULL;
IPersistStreamInit* pPersistStreamInit = NULL;
hr = pWebBrowser->get_Document( &pHtmlDoc );
if ( SUCCEEDED(hr) && pHtmlDoc)
{
  // Query for IPersistStreamInit.
  hr = pHtmlDoc->QueryInterface( IID_IPersistStreamInit,
                               (void**)&pPersistStreamInit );
  if ( SUCCEEDED(hr) )
  { 
     hr = pPersistStreamIni->Save(, True);
     pPersistStreamInit->Release(); 
  }
  pHtmlDoc->Release();
}

您提供浏览器和流媒体。HTH

--

Michael

A BHO or plugin would work.
There are so many options to get the source, it's kinda. pick your poising.
Look up IDocHostUIHandler to alter behaviour. IHTMLElementCollection to parse the page in browser.
The easiest thing I can think of at the moment is....

Save the current contents to a stream. same as get/view source.


// #include
HRESULT SaveDocumenttoStream(IWebBrowser* pWebBrowser,
IStream* pStream)
{
HRESULT hr;
IDispatch* pHtmlDoc = NULL;
IPersistStreamInit* pPersistStreamInit = NULL;
hr = pWebBrowser->get_Document( &pHtmlDoc );
if ( SUCCEEDED(hr) && pHtmlDoc)
{
// Query for IPersistStreamInit.
hr = pHtmlDoc->QueryInterface( IID_IPersistStreamInit,
(void**)&pPersistStreamInit );
if ( SUCCEEDED(hr) )
{
hr = pPersistStreamIni->Save(, True);
pPersistStreamInit->Release();
}
pHtmlDoc->Release();
}

You supply the browser and stream.HTH

--

Michael

情话难免假 2024-07-15 05:42:51

有趣的想法。 您可以复制 DOM holus-bolus,然后用副本替换新窗口的 DOM 吗? 这只是一个猜测。 此时我和你一样陷入黑暗。

Interesting thought. Could you copy the DOM holus-bolus and then replace a new window's DOM with the copy. It's just a guess. I'm as much in the dark as you at this point.

强者自强 2024-07-15 05:42:51

我认为这是不可能的,因为你必须考虑很多细节,总会有一些事情被打破。 仅提两点:

  • 您必须处理嵌入式 Web 浏览器(框架、IFRAME)。 我认为复制主页只会复制它们的 URL,因此当您在某处恢复序列化主页时,它们的内容将被重新加载,从而页面的内容会发生变化。 所以你必须深入到框架级别。
  • 您必须注意脚本,这些脚本会在您背后尝试连接到某个服务器以发送您分叉的页面已经发送的数据。 所以你可能会改变页面的逻辑。

因此,实时处理是捕获用户所见状态的唯一真正解决方案; 如果这是您想要实现的目标。 如果您不需要那么多细节,可能会更容易做到。

I think it is impossible to do because you have to think about so many details, something will always break. Just to mention two:

  • You have to take care of embedded web browsers (frames, IFRAMEs). I think copying the main page would just copy their URLs so their content will be reloaded when you restore the serialized main page somewhere, thus the content of your page changes. So you would have to go down to the frame level.
  • You would have to take care about scripts which behind your back try to connect to some server to send data which has already been sent by the page you forked. So you might change the logic of the page.

So processing live is the only true solution to capture the state as the users sees it; if this is what you want to achieve. If you don't need so much detail it might be easier to do.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文