Logo
My Account |  Site Map | Contact Us  
Welcome Guest Search | Active Topics | Sign In | Register

Open a new window form WebBrowserControl Options
Riki
Posted: Wednesday, May 10, 2017 8:05:24 AM
Rank: Newbie
Groups: Member

Joined: 10/9/2016
Posts: 7
Hi,

I have a HTMl page that open and close another window, by using js function: "window.open" and "window.close"

I did implenents the NewWindowEvent and set the "Accept" Property to true,

Nothing happend!!!!!!!

I must open the target url in a new window,not in new tab and not in the current window,


do you have any soulution?

very urgent

thanks

rivka
eo_support
Posted: Wednesday, May 10, 2017 8:26:08 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 19,749
Hi,

You need to display e.WebView. Just setting e.Accepted to true is not enough. The follow of the event is like this:

1. window.open is called;
2. The browser engine creates a new WebView and pass this WebView to you through e.WebView;
3. You set e.Accepted to true, this tells the browser engine that you will display this newly created WebView to the end user;
4. The browser engine waits for the new WebView to be displayed and initialized;

If you do not display e.WebView, then the flow will stop at step 3.

Exactly how to display e.WebView is up to you. For example, if you use Windows Forms, you can do that by placing it in a new Form and call Form.Show(). In our TabbedBrowser sample, we create a new tab and place the new WebView in that tab, then activate that tab to show it.

Hope this helps.

Thanks!
Riki
Posted: Thursday, May 18, 2017 3:00:38 AM
Rank: Newbie
Groups: Member

Joined: 10/9/2016
Posts: 7
Hi,

the new window works well,

But, when I want to change text on the original window' by using "window.opener".

For example window.opener.selectCustomer('220793251','1').

the original window do nothings!!!

in Chrome Browser its work fine.

can you help me?

thanks

Rivka

eo_support
Posted: Thursday, May 18, 2017 11:27:21 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 19,749
You can use the built-in developer console to debug your code to find out what's wrong. The most common mistake is instead of displaying e.WebView, you create a new WebView and set the new WebView's Url to the new Url. If you do this the new Url will be displayed, but the new window will have no relationship with the opener window (window.opener will be null).
Riki
Posted: Sunday, May 21, 2017 3:57:41 AM
Rank: Newbie
Groups: Member

Joined: 10/9/2016
Posts: 7
I did it already, 'window.opener' (in js) still not working!

Here is my code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using EO.WebBrowser;
using EO.WebBrowser.WinForm;
using TY.CommonData;
using TYUI.General;

namespace TY.UIStructure
{
public partial class WebBrowserForm : Form
{
public WebBrowserForm()
{
InitializeComponent();
}

private WebView m_wvInfo;
private WebControl m_wcInfo;
private string errorMessage;

public void Initialize(string url)
{
//EO.WebBrowser.Runtime.RegisterCustomSchemes("sample");

//Initialize the WebControl that is used to
//display sample UI HTML
m_wcInfo = new EO.WebBrowser.WinForm.WebControl();
this.Controls.Add(m_wcInfo);
m_wcInfo.Dock = DockStyle.Fill;

m_wvInfo = new EO.WebBrowser.WebView();
m_wvInfo.Url = url;

m_wcInfo.Refresh();
m_wcInfo.WebView = m_wvInfo;
m_wvInfo.UrlChanged += m_wvInfo_UrlChanged;

m_wvInfo.BeforeContextMenu += m_wvInfo_BeforeContextMenu;
m_wvInfo.Shortcuts = new EO.WebBrowser.Shortcut[]
{
new EO.WebBrowser.Shortcut(EO.WebBrowser.CommandIds.Reload, EO.WebBrowser.KeyCode.F5, true, false, false)
};

m_wcInfo.WebView.NewWindow += WebView_NewWindow;
}



void WebView_NewWindow(object sender, NewWindowEventArgs e)
{
e.Accepted = true;

InitializeNewWindowWW(e.WebView, e.TargetUrl);
}

private WebView _webView;
private WebControl newPageWC;

private Form newWindow;
private void InitializeNewWindowWW(WebView webView, string targetUrl)
{
newWindow = new Form();
newWindow.StartPosition = FormStartPosition.CenterScreen;

//Initialize the WebControl that is used to
//display sample UI HTML
newPageWC = new EO.WebBrowser.WinForm.WebControl();

newWindow.Size = new Size(800, 700);
newWindow.Controls.Add(newPageWC);
newPageWC.Dock = DockStyle.Fill;

_webView = webView;
_webView.Url = targetUrl;

newPageWC.Refresh();
newPageWC.WebView = _webView;
_webView.UrlChanged += m_wvInfo_UrlChanged;

_webView.Closed += WebViewOnClosed;

newWindow.Show();
}


private void WebViewOnClosed(object sender, WebViewClosedEventArgs webViewClosedEventArgs)
{
newWindow.Close();

newWindow.Dispose();
}


#region Events

private void m_wvInfo_BeforeContextMenu(object sender, EO.WebBrowser.BeforeContextMenuEventArgs e)
{
e.Menu.Items.Clear();
}

private void m_wvInfo_UrlChanged(object sender, EventArgs e)
{
if (m_wvInfo.Url.Contains("close"))
{
this.Close();
}

}

private void WebBrowserForm_Load(object sender, EventArgs e)
{

}

#endregion
}

}



can you help me please?


thanks

Rivka

eo_support
Posted: Sunday, May 21, 2017 11:58:25 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 19,749
You can NOT set WebView.Url in your handler. Remove the following line in your code:

Code: C#
_webView.Url = targetUrl;


Thanks!
Riki
Posted: Monday, May 22, 2017 3:30:48 AM
Rank: Newbie
Groups: Member

Joined: 10/9/2016
Posts: 7
Thank you!!! It's working!!!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.