C# webbrowser control: page opens new window but it won't work - webbrowser-control

I use a webbrowser control (in C# - latest version of visual studio and .NET) to allow me to read and write data to a specific web page. Everything is OK until I reach the point that the page attempts to open a pdf document in a new window (the page contains javascript code).
The new window opens OK on my IE. But nothing appears when the webbrowser control opens the new window...
I've tried setting firefox as my default browser to see if it makes any difference but no good came out of it. The webbrowser control still opened IE.
I've tried catching the event of the new window and refer the url to another webbrowser control... no success again!
How can I get the pdf document? And why would the new window open but not display the pdf?

Related

How to find xpath in a new window handle

My site has a button that opens a new window handle.
I recognize the new window handle and switch to it.
when I try to inspect elements on this new handle I must press F12 and the DevTools open in a new window.
I enter my xpath and it highlights the object correctly.
when I search the object in my code it does not find it, and it seems that the HTML is not complete.
Any ideas?

Access WebView2 newly opened window

If I run window.open("url") it will open url in new popup window, even if it is Edge WebView2. It will just have default Windows title-bar, and read-only url bar. I need to open url from WebView exactly in new popup window, via window.open("url").
Is there any way to access that window from my program as far as original WebView2 child-window? By accessing I mean injecting scripts, and getting js-response after injecting.
Or, at least, perhaps there is way to open url with some pre-injected script, like window.open("http://google.com -javascript: alert(5)")?
Update
Found MSDN article, probably this is what do I need. Trying to understand that.
Yes, the ICoreWebView2::add_NewWindowRequested event lets you intercept WebView2 opening new windows.
If you do nothing in the event handler, or don't subscribe to the event, you'll get a new popup like you describe. In script the return value of window.open is connected up to the newly opened popup window. But in your native code you have no access to or control over the newly opened window.
Or you can set the Handled property to true on the NewWindowRequested event's args, and no new window will be created. This is useful if you want to prevent opening windows or if you want to send new window opens to the default browser or somewhere else. In script the return value of window.open is null.
Or you can provide your own ICoreWebView2 via the NewWindow property. In this case you are responsible for and get to choose how to host that ICoreWebView2 in some manner. The ICoreWebView2 you provide as the NewWindow will be the target of the new window navigation and connected back up via script to the return value of the window.open call.
Because obtaining a new WebView2 may require asynchronous method calls, you can use the GetDeferral method on the event args to stop the completion of the window requested event until you call Complete on the deferral asynchronously later.
You can see a working sample of the add_NewWindowRequested event in our sample app.

VB.Net Webbrowser Inspect Element

I've been trying to figure out the ID of a button on a webpage in the VB webbrowser, but as VB uses an outdated web browser so the webpage loads differently to chrome so I can't figure out what the ID of the button is.
Is there any way I can get the ID of a focused element with some code?
Or alternatively, what web browser does VB use, so I can do figure it out manually.
Thanks!

MS Access Form with Webbrowser Control Popup New IE Window, Access 2010/VBA

I have struck with one issue not finding any workable solution. Googled a lot without any success…HELP PLEASE.
Situation: Using MS Access 2010, there is one Form with WebBrowser Control (Unbound) for conducting some search, when I click the results of the search a Pop-up new Internet Explorer window opens for the search result.
Requirement: I need “new Internet Explorer window” needs to be opened on existing WebBrowser Control..... NOT to open separately as new pop-up Internet Explorer window.
Kindly provide me solution (MS Access 2010/VBA) or workaround….
Regards,
Sandy
Can you open the form that you are opening in the WebBrowser Control in a new browser window outside of the application in order to test something. Check to see, if when you open the url, and then invoke the search, if the results open in a new window for that browser. If so, then check the target of the form within the first screen to get the name of the window that the page is trying to open the results in. If the target is specified, then you will need to write code to remove it when the page loads.
Just assign the new web address to your webbrowser control. something like this. Note it has to include equal sign and a hyper-link surrounded by quote.
Private Sub WebBrowser34_Click()
Me.WebBrowser34.ControlSource = "='www.google.co.uk'"
End Sub

accessing the controls on a webpage I have just opened

I have a piece of code that opens a web page in my default browser (IE10).
Dim url As String
url = "http://www.google.com"
Process.Start(url)
How do I then pass a value to the text box on that page. I am using google as an example. I am using VS2013, VB and asp.net
Thanks
This video should give you all of the information that you need. It is a tutorial on creating an automatic yahoo login from vb, but it will show you how to pass values to a textbox on a webpage, as well as working with other webpage controls.
NOTE: You will need to navigate to the page and view source to get the id of the controls