Handle new windows in Cefsharp (Winforms) - c#

I'm new to cefsharp and i cant seem to wrap my head around how I'd be able to handle popups in the simplest manner. These are popups such as when the page requests a new tab, or even when a confirm/alert is fired.
Everything is fine and all with the default settings, but I want the popup's title bar to show a predefined text, like for instance my app's name. By default it shows the url which requested the popup and i don't want that. Besides that, everything can remain as it is.
Any idea how i could achieve this?

Related

Hook into tab changed event of browser

In an ongoing project (Windows, .NET C#) we encountered a bottleneck in our development:
we have to observe the change of the current tab in all major browsers (IE,FF, Chrome, Opera, Safari).
As soon as tab change event has been captured, it must be written to a file.
Is this feasible?
What i finally did was the following:
tracked the EVENT_OBJECT_NAMECHANGE for the Window title
as soon as the title gets changed i know there was something "new" loaded, so i checked for the URL of the browser using various techniques (nDDE for Firefox and Opera, checking for a specific Window Class for Chrome, etc...! Thorsten is right by saying that it's impossible, so i implemented only for the major browsers)
I don't know how this should be done... One thing you could try is to find the window handle of the browser's tab control and hook into it, but that's quite a nasty task. And there's no guarantee that they don't use a custom tab control, so I'd say this can't be done.
Can you give some more information on why you need this? Maybe there's some other solution you didn't think of?
You can combine these two to get what you want:
Is there a way to detect if a browser window is not currently active?
And:
Javascript; communication between tabs/windows with same origin

window.showModalDialog and whatever permutation of WebBrowser

Is there anyway to get access to or control the windows that pops up from JS calling window.showModalDialog?
I am currently using the WPF webbrowser which as I've noticed has very limited help in this area so I tried switching over to the Forms.WebBrowser version but that also doesn't seem to help me... I tried all the different permutations of newwindow events but they only fire when a completely new IE window pops up like from a _blank target...
The window that pops up has a series of check boxes I need to click through and then click OK from code
the best thing I've figured out as a plan so far is to inject some JS that emulates the return parameter of the dialog. But I was curious if there's a way to control or access this dialog from code...

How to pop a web browser from Silverlight OOB?

I want to pop a web browser popup window, with a given url, from Silverlight.
When running within the browser I use HtmlPage.Window.Invoke() to run a javascript and its window.open() in the host browser. Works fine.
But when I run out-of-browser (OOB) this technique obviously doesn't work. So, what to do?
Silverlight 4 has this new WebBrowser control for use when running OOB. It works fine, but I have only been able to run it in a child window within the silverlight application boundaries.
Then there is this hyperlink trick. Also works, but it creates a new tab in the current browser-instance. Not exactly what I want either.
Anything I have missed?
(Alternatively; is there a a way to make the hyperlink pop the url in the same browserinstance and tab every time? instead of creating new tabs.)
Bit of a long post this. Sorry about that and thank you for your patience.
The link you posted to creating a derived HyperlinkButton is the only one I know of. Maybe play around with different TargetName values to see which one works like you want? "_blank", "_new", etc... - one of them may be what you want.
The trouble is that different browsers (when set as the default browser) may do different things, so be sure to try this with IE, Firefox, on a Mac, ...

How to open new web page in a tab In IE 8 in C#

Hi Experts
How I can open several URL in tabs in IE 8 using c#?
thanks
There is no guaranteed way to control that a new window that you open will be opened up specifically as a new tab. This is because most browsers have this control as a user defined setting.
As far as i can remember, when using window.open in javascript, the best you can do is use target = '_blank' to specify that the target will always be opened in a new window. However, whether this new window is in fact just a new tab or an actual new window is controlled by the users browser setting in tabbed browsers
Make sure you get your hands on the IWebBrowser2 interface of the webbrowser object, then use the Navigate method. Passing navOpenInNewTab in the flags will open the navigated URL in a separate tab.
Pitfalls: do not mix with other flags, do not mix with headers and/or postdata.

Curious pop-up behavior when using WebBrowser class

My C# application includes an embedded web browser, which is made possible by the System.Windows.Forms.WebBrowser class. Users are able to navigate to websites using the app, however, when they encounter a page that includes a pop-up window, the pop-up window is opened by Internet Explorer.
Does anyone know how to suppress that behavior?
NOTE: I'm new to C#, so please take that into consideration when responding.
Are you looking to actively block popups or handle them in your application? If you're wanting to customize the blocking, then you'll have to implement the DWebBrowserEvents2 interface, specifically the NewWindow3 method. NewWindow3 method has specific functionality for blocking window popups (i.e. setting the Cancel parameter to true). These methods will also let you show your own window if you wish, though you'll have to provide your own Form to host yet another WebBrowser.
If you'd like to see some real C# source code providing advanced functionality with the WebBrowser control, I'd have to say that this article on CodeProject provided almost everything I know about the WebBrowser control. Be sure to download the source!
#Kramii is correct that you can also use the NewWindow2 event to prevent the popup. NewWindow3 provides additional parameters for if you're looking to inspect the URL or other data about the navigate to actually sometimes block and sometimes handle the popup yourself.
IIRC you can trap the NewWindow2 event on the WebBrowser control and set Cancel = true to prevent the pop-up.
This article may help:
http://www.codeproject.com/KB/cpp/ExtendedWebBrowser.aspx#GoalBlock

Categories

Resources