im don't know so much english so im soory// try to understand.

i made a browser//
but alawys when i get into some websites its open some more pages in internet explorer page and its not good// i want that it won't open this pages at all or if its open it so open it in my browser/ so how cann i block thats popups?


and i want like a normal browser that when i click at the mouse middle button at some link at website its will open the link in new tab

thanks!!

Recommended Answers

All 5 Replies

soooommmeeeeeeone!?!?!!!

I'm not entirely sure how to accomplish this as I've never had a problem with my own experiences in using the web browser control. The only thing I can think of would be to use the NewWindow event handler:

WebBrowser wb = new WebBrowser();
wb.NewWindow += new CancelEventHandler(wb_NewWindow);

void wb_NewWindow(object sender, CancelEventArgs e){e.Cancel = true;}

Though I warn you, I have not tested if that will block a popup or not. Theoretically it should but I can't offer any guarantees.

[Links]
http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.aspx
http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.newwindow.aspx

[Edit]
After reviewing a few more things for blocking popups via the web browser control it would appear that whatever settings you have in the actual browser will affect what happens in the control. Though it seems that it is still possible to implement your own. Again, this is only a superficial research on a much broader and or larger topic. I apologize that I cannot offer you more on the topic.

[Links]
http://bytes.com/topic/c-sharp/answers/277931-does-webbrowser-control-net-2-0-support-blocking-pop-up-windows
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/cbfd879c-6bc5-462b-8f58-f45e492ca29e

i dont know there all wrong with this line:
wb.NewWindow += new CancelEventHandler(wb_NewWindow);

and maby you know this?

"and i want like a normal browser that when i click at the mouse middle button at some link at website its will open the link in new tab"

The code I posted was an example for you to use on your own to show you how to add the event handler and will fail for copy/paste. I don't know what you named your browser in your own application so there is no realistic way for me to provide "plug-n-play" code.

My recommendation would be to add the event handler either after InitializeComponent() is called or during the form load event.

[Links]
http://msdn.microsoft.com/en-us/library/ms743596.aspx
http://www.google.com/search?q=how+to+add+event+handlers+c%23

As for allowing it to open up in a new tab, you're going to have to have tab support for your current application (to my knowledge the web browser control only gives you a basic web browser, tab controls have to added manually).

Assuming it does, you'll have to create a tab, button, something the user can click that when they do, allows a new tab to be added. The best solution that I can think of, would be to make a class or method that would automatically add all you want to the new tab.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.