|
Rank: Advanced Member Groups: Member
Joined: 12/30/2013 Posts: 68
|
In my app that is being converted, I have a number of handbook and videos that are seen by the user.
When the user clicks on the download button inside your webbrowser control, A new window/page is not created instead a popup message "The current page is tries to open a new window. Please handle NewWindow event." This is not a deprecated browser issue, It is nothing more then opening up a file in a new page. Here is the code I am using.
<a target="_blank" href="02 - Sample Help file.pdf">download</a></td>
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, You need to do exactly what the message says: handling NewWindow event. The difference between EO.WebBrowser and a traditional web browser is EO.WebBrowser is just the engine part, whereas the "frame" that the engine sits on are to be provided by you. On the other hand, a traditional "real" web browser has both parts. When a link with a different target is clicked, the browser engine notifies you that a new "window" is being opened (through NewWindow event). However exactly how you want to open that new window is up to you. Your code can choose to ignore it (thus have the same effect as "popup blocker"), or can display it in a new tab, or can display it in a new dialog, etc. Or you might want to implement complex logic, for example, only allow popup from a certain list of hosts. Whatever way you want to do it is up to you and different users might want to handle it different ways. This is the why you must handle this event to do exactly what you want to do there. The actual code can be very simple: For example, if you want to implement a popup blocker, you simply handle the event but leave the event handler empty. If you want to display the new page is a Form, you simply create a new Form, place the new WebView inside the form and show it. You can find details about this event here: http://www.essentialobjects.com/doc/6/advanced/new_window.aspxYou can also take a look of the TabbedBrowser sample to see sample code of how this is handled. The sample code is for WPF, however the idea is exactly the same. There are additional comment in the sample code that you might find to be useful as well. Hope this answers your question. Please feel free to let us know if you still have any more questions. Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 12/30/2013 Posts: 68
|
Sorry, but I am a little confused. I have initialized private void webView1_NewWindow(object sender, EO.WebBrowser.NewWindowEventArgs e) { } In your sample code in wpf, you have //The new WebView has already been created (e.WebView). Here we //associates it with a new WebViewItem object and creates a //new tab button for it (by adding it to m_Pages) WebViewItem item = NewWebViewItem(e.WebView); m_WebViewsHost.Items.Add(item); m_Pages.Add(item.Page);
//Select the newly created tab mainTabs.SelectedIndex = m_Pages.Count - 1;
//Signifies that we accept the new WebView. Without this line //the newly created WebView will be immediately destroyed e.Accepted = true;
But since I am not using wpf, this makes no sence to me. I do not have the class WebViewItem that you have in the sample as a wpf wrapper.
This should not be that difficult, All I am trying to do is open the new page in a new tab/page.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, You need to: 1. Create a new Form (or whatever container, such as a TabPage); 2. Create a new WebControl, set the new WebControl's WebView to the new WebView; 3. Place the new WebControl inside the new Form; The code will be something like this:
Code: C#
//Create a new Form. You can replace this with
//another container control
Form form = new Form();
//Create a new WebControl. This is the bridge between
//Windows Form and WebView.
EO.WebBrowser.WinForm.WebControl webControl = new EO.WebBrowser.WinForm.WebControl();
//Set the WebControl to fill its parent
webControl.Dock = DockStyle.Fill;
//Set the WebControl to host the new WebView, which
//is created by the browser engine when user clicks the
//link. You must use e.WebView, you can not create your
//own WebView here
webControl.WebView = e.WebView;
//Add the WebControl into the Form
form.Controls.Add(webControl);
//Display the form
form.Show();
Hope this makes sense to you. Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 12/30/2013 Posts: 68
|
That makes a lot more sense to me, thank you. I do not understand why the webpage I am calling does not load. I have tried both webControl.WebView.Url = e.TargetUrl; and webControl.WebView.LoadUrl( e.TargetUrl); before the control is added to the form( form.Controls.Add(webControl);) I get a blank open form.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
Did you set e.Accepted to true? You do not need to set the new WebView's Url in your code. The browser engine will set it for you once the control returns from your code (your NewWindow handler) to the browser engine. However you must explicitly set e.Accepted to true if you wish the browser engine to continue loading.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 12/30/2013 Posts: 68
|
That is perfect, thank you. I would like to suggest since most people do not use MVC, that you convert your sample projects (for me the webbrowser) into ASP.NET project (non MVC).
Thank you again for your time in helping me with my issues.
|
|
Rank: Advanced Member Groups: Member
Joined: 12/30/2013 Posts: 68
|
It appears I was a little premature in my thank yous. While the PDF's open and view perfectly, the mp4's do not. I get a save message, then a blank screen. I ran the same test in your tab browser example, (logged into my test site, went to the page where the links are and clicked on the link for 1 of the mp4s.) I got the same result.Just a blank page. The video did not run.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, You need to call EO.WebBrowser.Runtime.AllowProprietaryMediaFormats in order to support MP4. See here for more details: http://www.essentialobjects.com/doc/6/advanced/html5.aspxYou can call this in your Main function before starting anything else. Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 12/30/2013 Posts: 68
|
Thank you for the reply. Unfortunately that did not work. I am sending my initializing function for the application. Please let me know what I am doing wrong.
public frmMain() { InitializeComponent(); EO.WebBrowser.Runtime.AllowProprietaryMediaFormats(); EO.WebBrowser.Runtime.AddLicense( "This is where my license goes"); try { Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); } catch (Exception ex) { //manage also these exceptions }
}
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, Try to call it in your Program.Main method. You need to do it before everything else --- even before your frmMain is created. A typical C# Windows Form program has a Program.cs that contains a Main method that calls Application.Run(new Your_Main_Form()). Make sure you call AllowProprietaryMediaFormats before that. If that still doesn't work, then you can try to isolate the problem into a test project and send the test project to us. We will be happy to take a look once we have that. You can find instructions on how to send a test project to us here: http://www.essentialobjects.com/forum/test_project.aspxThanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 12/30/2013 Posts: 68
|
That solved the issue. Thank you for your help.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
You are very welcome. Please feel free to let us know if there is anything else.
Thanks!
|
|