Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem unbinding events
Message
From
27/09/2005 12:04:35
 
 
To
27/09/2005 11:39:29
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
01053447
Message ID:
01053498
Views:
14
>>>Greetings,
>>>
>>>I'm successfully binding all onclick events for links in an HTML document using the following code...
>>>
>>>
>>>thisform.oEv = CREATEOBJECT("myHTMLDocumentEvents")
>>>loNodes = thisform.olecontrol1.Document.getElementsByTagName("A")  && Get links
>>>
>>>FOR EACH loNode IN loNodes
>>>       EVENTHANDLER(loNode,thisform.oEv)   && Bind the onclick event for the link
>>>ENDFOR
>>>
>>>
>>>Now I'm trying to unbind the events with the following code:
>>>
>>>
>>>loNodes = thisform.olecontrol1.Document.getElementsByTagName("A")
>>>
>>>FOR EACH loNode IN loNodes
>>>      EVENTHANDLER(loNode,thisform.oEv, .T.)  && unbind the onclick event for the link
>>>ENDFOR
>>>
>>>
>>>
>>>It seemed straight forward, but unfortunately the unbinding part never happens and the result always returns .F.
>>>
>>>Any ideas????
>>>
>>>Thanks in advance!
>>
>>From code it looks like this is an HTML hosted in webbrowser control, right? If so I don't think you need eventhandler,bindevents etc. for link and submit button clicks. You can use direct VFP code in BeforeNavigate2 event.
>>Cetin
>
>Thanks for the reply.
>
>My project started out using the beforenavigate2 event but I ran into trouble with links that contain _target=blank. Since they always open in a new window I had no way to trap them in beforenavigate2. The window would simply open up in a browser outside my app and it was as if my app never knew the user clicked the link. By trapping the onclick I can easily grab the href and keep the user on the page until I'm ready to send them on.
>
>I considered using some string manipulation to parse out the target=blank but in the long run I think the event handling is going to give me more control over what is going on than the beforenavigate2 can provide. One example maybe to allow users to click on images in the document to quickly que them up and save them to a folder.
>
>It may help to know the purpose of the app is to allow engineers with no programming skills to quickly accumulate product descriptions, links and pictures from a wide variety of manufacture websites so they can create design documents. Right now it's a very time consuming process for them to collect and organize this information. I looked into spiders and web extraction tools but we need something that is much more focused than what they offer if we are going to save significant time.


I hate responding to my own posts but I thought it could help someone else. I've found out that I can get rid of the target = _blank problem in links with the following code.
loNodes = thisform.olecontrol1.Document.getElementsByTagName("A")
 
FOR EACH loNode IN loNodes
  loNode.target = ""
ENDFOR
This will help eliminate some of the need to bind events in this project.
Previous
Reply
Map
View

Click here to load this message in the networking platform