How would I go about getting the link that was right clicked or left clicked on in a webbrowser control ?? I simply want to know so that I can create my own open in new window functions and stuff...
Thanx
AAG
Printable View
How would I go about getting the link that was right clicked or left clicked on in a webbrowser control ?? I simply want to know so that I can create my own open in new window functions and stuff...
Thanx
AAG
Try this:
VB Code:
Private Sub webbrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean) Dim NewFrm As New Form1 NewFrm.Show Set ppDisp = NewFrm.webbrowser1.object End Sub
hehe nah man thats not what i needed, I already know how to do that. I know quite a bit about the webbrowser control, so don't think i'm a beginner. Let me try and explain what i need to do. I have created a mousehook and trap the WM_RBUTTONUP message when the mouse is over the Webbrowser control, I cancel the original popup of IE, then I replace it with my own popup with special functions I have created. One of my functions is "Open In New Window", but I don't know how to get the url of the link that was right clicked on. I need this url so that i can Load a new instance of the webbrowser control and navigate to it. my problem is not that of creating a new window, its getting the url of the link. I cannot use the Status Text of the webbrowser control because some websites contain scolling text in the status and what not that will prevent the actual URL from being shown. I hope this has cleared things up....
Thanx for the reply though man, I appreciate it
AAG
lol ... I dont think he think that...Quote:
so don't think i'm a beginner.
hehe yea myabe not, but it never hurts to add that so that they don't waste thier time explaining things....
why cant you capture the URL on the before nav to?
or is your canceling killing it before this event?
I know there is another way but its been months since I've been playing with VB (busy at work learning Perl)
No VB here either so I can even try....
yea the Canceling of the New_Window2 event kills the before navigate event.... :( I've tried tons of different things and still nothing has proven to work. On some sites simply grabbing the status text works but as i've said before, alot of sites use the scrolling status so....
Maybe if you could try to add a hot key to the event, instead of right click and your menu you could maybe have the user hold Alt + LeftClick and have the link open in a new window. I'm sure that doesn't help you with your dilemma but of course I don't know anything about the web browser control your trying to use either. Try emailing Megatron your problem, I'm sure he knows the answer but maybe hasn't seen your post. ;)
I already have a key assigned to open a new window. If you ctrl+click it will allow the popup :) i wouild like the option in the menu also :)
is it possible to cancel the event after the before navigate has been called?Quote:
Originally posted by AAG
yea the Canceling of the New_Window2 event kills the before navigate event.... :( I've tried tons of different things and still nothing has proven to work. On some sites simply grabbing the status text works but as i've said before, alot of sites use the scrolling status so....
Here's a dodgy way to do it.
Right, you have the source code to the webpage. You can also get the mouse co-ordinates.
So you could figure out where, physically on the page, each of the links are. Then when the user clicks, just go through an array of regions on the screen. If the user is inside one of those regions, they're on a link, and you would know which one it was...
Either that, or are you able to get the text of the link ?
If so then you could compare that to the HTML source and figure out which link it was.
yeah, but that would be terribly hard to do
Well who ever said this job was easy :)
its gotta be easier than that... besides you would have to account for the fact that most people code "short Adresses" so you would have to add the website name that you are at now, and then put the link address after that if you used your second idea.
yea, believe me, i've thought about and tried all of those ideas... nothing seems to work, i didnt' try to whole getcursorpos and what not, that just seems way to crappy. hhee
the only idea i have is to let it open IE, grab the address, kill the process, and open a new form
but that way is so inefficient... i know there has to be a simple way... i wonder where bloodeye is, i guess i'll email him..