Re: Focus in webbrowser Control

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"???" <hanansa88@xxxxxxxxxxx> wrote in message
news:DF9B04BC-A257-4F4D-AB20-95449A4B4A7F@xxxxxxxxxxxxxxxx


"Mark J. McGinty" wrote:


"???" <hanansa88@xxxxxxxxxxx> wrote in message
news:835203C7-D3D1-42CF-8B80-44B11204B150@xxxxxxxxxxxxxxxx
Hi There,

I'm using a webbrowser control in my project (VB 6.0), and I want to
".setfocus" on certain control in the webbrowser it selt. For example,
if
I
want to focus on a certain picture in a site I won't have to press
"tab"
for
many times, but I just press something like
"webbrowser1.picture1.setfocus",
just like in a form when I want to focus on a textbox I write
"Text1.setfocus", does anyone know how to do that?

You will have to manipulate the DOM (exposed as the webbrowser.Document
property) just as you would do in script, inside the HTML document.
Something like:

webbrowser.Document.all("id_of_element").focus


-Mark


Thank you.


I Still quite didn't understand whatI need to do because I'm not that
familiar with DOM (whatever it means...)

DOM = document object model, with which HTML documents can be dynamically
manipulated. The root object in this hierarchy is the "document" object, as
standardized by W3C (and extended by Microsoft.) The webbrowser control
exposes a Document property; it is the document object of the web page
that's been opened in the webbrowser control.

Giving focus to an element within an HTML document requires DOM-level calls;
specifically, the focus method, supported by many different element types.
All you have to do is figure out how to consistently obtain an object
reference to the element you want to focused. If that element has an id
attribute, and it's unique in the document, it's easy. If not, it becomes a
little more challenging.

Here's a link to MS tech ref:

http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp

And here's a link to an IE extension that I've written, that allows you to
browse the DOM of any web page that displayed in IE [unless it eats the
contextmenu (right-click) event]:

http://www.pagespy.com


-Mark



.



Relevant Pages

  • Re: interact with IE/Webbrowser modal Save Webpage window from app that opened it, possible?
    ... Another option using IE itself would be to use the DOM ... | and then enter the filename and path in the "File name:" edit control, ... | When I use a webbrowser control or open a new IE window from the VB ... | send the filename and path to the 2nd VB program using a command line ...
    (microsoft.public.vb.general.discussion)
  • Re: Accessing an HTML documents objects
    ... > I'm trying to access the contents of an HTML document using the object ... I know this can be done by using the WebBrowser control but I don't ... control's visible property to false seems to prevent access to the DOM. ...
    (microsoft.public.vb.controls.internet)
  • Re: Searching web sub-pages
    ... into a WebBrowser control or IE instance). ... weren't thinking of using DOM to look for the keywords. ... so as to avoid the bloat of loading them ... Then I would just parse them with InStr. ...
    (microsoft.public.vb.general.discussion)
  • Re: Windowless WebBrowser control?
    ... > If you don't require the rendering services of the WebBrowser control, ... > documents, which you can manipulate, add elements to, set element attributes ... I've used just the MSHTML parser before and the DOM returned isn't ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)
  • Re: HOWTO Use WebBrowser Control to Open & Edit HTML File
    ... WebBrowser control to be the user interface, I need to open a text file, ... open the *.html document using WebBrowser.Navigate2 then merely rewrite the ... > Private Sub Command1_Click ...
    (microsoft.public.vb.general.discussion)