简体   繁体   English

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

[英]Fork or copy a users browser session in IE

Is it possible to fork a users session (or do something similar) in a Internet Explorer plugin? 是否可以在Internet Explorer插件中分叉用户会话(或执行类似操作)?

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. 处理可能涉及诸如在Google搜索上加载结果链接的内容之类的内容,如果这是点击按钮的位置。

So - what I basically want is to imitate " Ctrl+N " but hide the window from the user, so they won't be interrupted. 所以 - 我基本上想要的是模仿“ Ctrl+N ”但是隐藏用户的窗口,这样它们就不会被打断。

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. 如您所见,如果您在http://www.snee.com/xml/crud/posttest.html上填写并提交表格并按“ Ctrl+N ”,则发布的所有内容仍会显示在新窗口中,但它不会发布两次数据。

I was thinking of somehow copying the IWebBrowser2 , but: 我想以某种方式复制IWebBrowser2 ,但是:

  • I'm not sure if that's possible (I haven't been able to find any information on MSDN) 我不确定这是否可能(我无法在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. 创建IWebBrowser2的新实例并简单地导航到当前URL不是一个有效的解决方案,因为POST变量当然不会被转移。

A BHO or plugin would work. BHO或插件可以工作。 There are so many options to get the source, it's kinda. 有很多选择来获取源,它是有点。 pick your poising. 选择你的平衡。 Look up IDocHostUIHandler to alter behaviour. 查找IDocHostUIHandler以更改行为。 IHTMLElementCollection to parse the page in browser. IHTMLElementCollection在浏览器中解析页面。 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 您提供浏览器和stream.HTH

-- -

Michael 迈克尔

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). 您必须处理嵌入式Web浏览器(帧,IFRAME)。 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. 我认为复制主页只会复制其URL,以便在您将序列化主页恢复到某处时重新加载其内容,从而更改页面内容。 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. 如果您不需要那么多细节,那么可能会更容易。

Interesting thought. 有趣的想法。 Could you copy the DOM holus-bolus and then replace a new window's DOM with the copy. 你可以复制DOM holus-bolus,然后用副本替换一个新窗口的DOM。 It's just a guess. 这只是猜测。 I'm as much in the dark as you at this point. 在这一点上,我和你一样黑暗。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM