简体   繁体   English

Winform中2个Web浏览器之间是否可以进行javascript通信

[英]Is it possible to have javascript communication between 2 WebBrowsers in winform

I have a winform with 2 WebBrowser control. 我有一个带有2 WebBrowser控件的winform。 Is there a way for one page to communicate with the other directly? 是否有一种方法可以使一个页面直接与另一页面通信?

For example in HTML and frames, one page can access window.parent.frames[1].document for example. 例如,在HTML和框架中,一页可以访问window.parent.frames [1] .document。

Not directly, because those will be two separate browser instances. 不直接,因为它们将是两个单独的浏览器实例。 You can however write some communication layer of your own. 但是,您可以编写自己的一些通信层。 Obviously you'll have to tailor the websites you are showing for this as well. 显然,您也必须为此定制显示的网站。

Technically it is feasible like the web chat between two or more people in Gmail or Facebook. 从技术上讲,这是可行的,例如Gmail或Facebook中两个或多个人之间的网络聊天。

This is not a simple task, but today there is the HTML5's websockets or if you target older browsers as well, you could poll the server on both frames and share some statuses that you read every few seconds. 这不是一个简单的任务,但是今天有了HTML5的websocket,或者如果您也针对较旧的浏览器,则可以在两个框架上轮询服务器,并共享每隔几秒钟读取的一些状态。

In any case, this is a messaging(string) communication (eg: a stringified JSON) that you can pass. 无论如何,这是您可以传递的消息传递(字符串)通信(例如,字符串化的JSON)。
But you will never be able to access the DOM of the other browser/frame. 但是您将永远无法访问其他浏览器/框架的DOM。

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

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