Does anyone know how to send a URL to an already open window of a browser? At the moment i have to close the original window then open a new window with the new URL i want. Help!
Printable View
Does anyone know how to send a URL to an already open window of a browser? At the moment i have to close the original window then open a new window with the new URL i want. Help!
I presume you are asking how to do this in VB. If so, it is easy. I have several programs that either open a browser, and connect to a web page, or, if the browser is already open, go to a designated web page, all with one mouse click. I have developed my own web address book in VB, and have my favorite web sites displayed in a listview control. All I do is click on the web site I want, and my program takes me there. Place the following in the declarations section of a form:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
In a button click event, put:
Dim OpenPage As Long
OpenPage = ShellExecute(frmWebSites.hWnd, "Open", "http://forums.vb-world.net/", 0&, 0&, 0&)
Substitute frmWebSites with the name of your form, and substitute the web address with the address of your choice. In my code, the web address is actually a variable that is set in the click event of the listview control. Hope this helps.
Hey thanks! I used the ShellExecute method before and all it did was open a new instance of the browser. I have no idea how it works now, but thanks!