Open YouTube Embedded Player link in default browser - c#

I'm hosting YouTube Embedded Player in C# WebBrowser control. When I click button "Watch on YouTube" IE opens. Is there any way to open the link in default web browser, for instance, Chrome?

Like this for example:
private void browser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
System.Diagnostics.Process.Start(e.Url.ToString());
e.Cancel = true;
}
Explanation: change the navigating handler to process the URL and fire the link in the diagnostics (which will open the URL in the user’s default browser).

Related

Open new page in standard browser when link is clicked

I can open the link in my standard browser with this code:
public void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
//cancel the current event
e.Cancel = true;
//this opens the URL in the user's default browser
Process.Start(e.Url.ToString());
}
But the problem is that IE only should be opened when a link on the webbrowser is clicked. When using this code IE also opens when I change the documenttext.
My suggestion would be to take a different approach. At the point in time immediately after the initial page has loaded in the WebBrowser control (Navigated event), you can use the webBrowser1.Document property to retrieve an HtmlDocument instance.
From this you should be able to find your link by using, for example,
http://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.getelementbyid(v=vs.110).aspx
Then you can add an event handler to detect when this link is clicked, and in this handler, run your code to start the IE process.

How to automatically accept the "Open/Save Dialog" in a WebBrowser Control?

I am working on a c# Windows utility, which is opening a file using webbrowser control.
webBrowser1.Navigate("URL");
URL is actually an attachment, which is showing as "Open" "Save" dialog
private void WebBrowser1_FileDownload(Object sender, EventArgs e)
{
textbox1.text ="filedownload event fired!!"
}
can I do somthing so that i cancel the file open/save dialog in the background.
As I wanted to automate the process and don't want user to get popped up message.

Window.Print() block other google chrome tabs

I am working on ASPx Web Forms Page and have problem with printing page.
I have button 'Print' which calls event (print method):
private void MenuPrint_ItemClick(object sender, DevExpress.Web.ASPxMenu.MenuItemEventArgs e)
{
Response.RedirectOn("Print.aspx", "_blank", "menubar=0,scrollbars=1,width=780,height=900,top=10");
}
after I press 'Print' button it opens new window 'Print.aspx' and this is which is on this Page:
protected void Page_Init(object sender, EventArgs e)
{
LoadData(); // generate print document
Response.Write("<script language=javascript>window.print();</script>");
}
and now it's the problem:
window.print(); will open google chrome printing menu, which block old window (that window where is 'Print' button.
When I close Print.aspx by clicking [X] List.aspx windows will be still blocked. When I press 'Anuluj' - which means Cancel and then press [X] List.aspx won't be blocked. Eveything will be fine.
I make some research and figure out that there is no more options to print document, also I can't handle 'Cancel printing' button.
Question is how to avoid that block, maybe I should use something other instead RedirectOn?
This seems to be a bug of Chrome 34 - is this the Chrome version you are using?
There is a similar question open here: Javascript window.print() in chrome, closing new window or tab instead of cancelling print leaves javascript blocked in parent window.
No solution so far though.

Change the textbox(URL) text on back button press in Windows phone app

I have developed a web browser using the WebBrowser API in Visual Studio for a Windows Phone application) I have add a back button to this web browser. This is the code that I use for the back button to go to previous web page:
private void backOnClick(object sender, RoutedEventArgs e) {
webBrowser1.InvokeScript("eval", "history.go(-1)");
}
So now I want to change the textbox(URL) text considering the web page when press back button. How can I do that?
On your LoadComplete event on the WebBrowser control, look at the Source property and sett that into the TextBox (that's also useful for redirects).

click on a link event webbrowser c#?

I want to open a link in IE browser from the web browser control in my winform ... the webbrowser control navigate to a page when the user click on a link it opens in the internet explorer browser.
Basically handle the WebBrowser.Navigating Event, cancel the navigation and open up the url in explorer like this:
private void WebBrowserNavigating(object sender, WebBrowserNavigatingEventArgs e)
{
e.Cancel = true;
Process.Start("iexplorer.exe", e.Url);
}

Categories