CEFSHARP如何在Windows中打开的新页面。
我的Winform应用程序使用CEFSHARP
, 当我打开page1.html
in cefsharp
, page1.html
不是我自己的页面,我无法控制此页面的代码。 page1.html
代码看起来像这样:
<html>
<head>
<title>page1</title>
</head>
<body>
this is page 111
<script language=javascript>
var toUrl="http://localhost/KintechToGica22/page2.html";
window.open(toUrl,'openTest2','');
</script>
</body>
</html>
我可以将js注入page1.html
与以下C#代码
//ChromiumWebBrowser browser = (ChromiumWebBrowser)sender;
string text = System.IO.File.ReadAllText(@"c:\my.js");
browser.ExecuteScriptAsync(text);
I使用window.poin.open.open
代码> pag1.html 要打开页面page2.html
, page2.html
代码看起来像这样:
<html>
<head>
<title>page2</title>
</head>
<body>
this is Page 222
</body>
</html>
但是我如何控制page2.html
, 我想用page2.html
注射JS做某事
My Winform application uses CefSharp
,
When I open page1.html
in CefSharp
,
the page1.html
is not my own page and I have no control over the code of this page.
The page1.html
code looks like this:
<html>
<head>
<title>page1</title>
</head>
<body>
this is page 111
<script language=javascript>
var toUrl="http://localhost/KintechToGica22/page2.html";
window.open(toUrl,'openTest2','');
</script>
</body>
</html>
I can inject JS into page1.html
with the following c# code
//ChromiumWebBrowser browser = (ChromiumWebBrowser)sender;
string text = System.IO.File.ReadAllText(@"c:\my.js");
browser.ExecuteScriptAsync(text);
I use window.open
in pag1.html
to open a page page2.html
,
The page2.html
code looks like this:
<html>
<head>
<title>page2</title>
</head>
<body>
this is Page 222
</body>
</html>
But how do I control page2.html
,
I want to do something with page2.html
injection JS
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
window.open
调用将创建一个新的弹出窗口。您可以通过实现。一个基本示例看起来像:
The
window.open
call will create a new popup. You can get load events for popups (and main browser) by implementing LoadHandler.A basic example would look something like: