|
|
|
date: Fri, 4 Jul 2008 03:40:27 -0700 (PDT),
group: microsoft.public.win32.programmer.ole
back
Re: How to get dynamic attribute at runtime
On Jul 4, 9:45 pm, "Igor Tandetnik" wrote:
> wrote in message
>
> news:c7537469-708e-4598-ae8e-3fb5badcbc16@w8g2000prd.googlegroups.com
>
> > I have a simple tool works like the IE Developer toolbar. When I move
> > the mouse over the HTML page, it can retrieve the element information
> > under the mouse. But if the attribute is set by JS at runtime.
>
> How do you retrieve the attribute? How does JS set the attribute?
> --
While I hover the mouse the item, it is applied a hight-light effect,
by applying a new "class" attribute. So I think the "class" attribute
is set during the "onmouseover" callback.
To retrieve the attribute I use "IHTMLElement::getAttribute" method.
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
date: Sat, 5 Jul 2008 02:21:07 -0700 (PDT)
author: unknown
Re: How to get dynamic attribute at runtime
wrote in message
news:f6d6d101-d11b-4d31-8704-5a7e0add5d24@k13g2000hse.googlegroups.com
> On Jul 4, 9:45 pm, "Igor Tandetnik" wrote:
>> wrote in message
>>
>> news:c7537469-708e-4598-ae8e-3fb5badcbc16@w8g2000prd.googlegroups.com
>>
>>> I have a simple tool works like the IE Developer toolbar. When I
>>> move the mouse over the HTML page, it can retrieve the element
>>> information under the mouse. But if the attribute is set by JS at
>>> runtime.
>>
>> How do you retrieve the attribute? How does JS set the attribute?
>
> While I hover the mouse the item, it is applied a hight-light effect,
> by applying a new "class" attribute. So I think the "class" attribute
> is set during the "onmouseover" callback.
Are you sure? Have you looked at JavaScript code doing this, or are you
just guessing?
What's the URL of the page you are testing on?
> To retrieve the attribute I use "IHTMLElement::getAttribute" method.
If the script really manipulates "class" attribute, try also with
IHTMLElement::get_className. I doubt it would make a difference though.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
date: Sat, 5 Jul 2008 11:51:56 -0400
author: Igor Tandetnik
Re: How to get dynamic attribute at runtime
On Jul 5, 11:51 pm, "Igor Tandetnik" wrote:
> wrote in message
>
> news:f6d6d101-d11b-4d31-8704-5a7e0add5d24@k13g2000hse.googlegroups.com
>
> > On Jul 4, 9:45 pm, "Igor Tandetnik" wrote:
> >> wrote in message
>
> >>news:c7537469-708e-4598-ae8e-3fb5badcbc16@w8g2000prd.googlegroups.com
>
> >>> I have a simple tool works like the IE Developer toolbar. When I
> >>> move the mouse over the HTML page, it can retrieve the element
> >>> information under the mouse. But if the attribute is set by JS at
> >>> runtime.
>
> >> How do you retrieve the attribute? How does JS set the attribute?
>
> > While I hover the mouse the item, it is applied a hight-light effect,
> > by applying a new "class" attribute. So I think the "class" attribute
> > is set during the "onmouseover" callback.
>
> Are you sure? Have you looked at JavaScript code doing this, or are you
> just guessing?
>
> What's the URL of the page you are testing on?
>
Pretty sure. I have tried it on many public site.
> > To retrieve the attribute I use "IHTMLElement::getAttribute" method.
>
> If the script really manipulates "class" attribute, try also with
> IHTMLElement::get_className. I doubt it would make a difference though.
Yep. IHTMLElement::get_className really solves my problem. But I want
to know if there are any universal way to get the attributes. If I
have to write specific code to get sepcific attribute, my code would
be in a mess and difficult to maintain. I have tried IHTMLDOMAttribute
and IHTMLDOMAttribute2, the behavior of both are odd...It does works
with "class" attribute. But if I tried to get "align", my app crash. I
have not troubleshooted this, however, I could get "align" by
getAttribute. And If you try to get "offsetWidth" attribute, my app
would suspend until I kill it.
Do you have any good ideal to help work this out? Thanks.
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
date: Sun, 6 Jul 2008 02:22:23 -0700 (PDT)
author: unknown
Re: How to get dynamic attribute at runtime
wrote in message
news:0130fe3d-e498-4906-be85-353e39dcd359@27g2000hsf.googlegroups.com
> Yep. IHTMLElement::get_className really solves my problem. But I want
> to know if there are any universal way to get the attributes. If I
> have to write specific code to get sepcific attribute, my code would
> be in a mess and difficult to maintain. I have tried IHTMLDOMAttribute
> and IHTMLDOMAttribute2, the behavior of both are odd...It does works
> with "class" attribute. But if I tried to get "align", my app crash. I
> have not troubleshooted this, however, I could get "align" by
> getAttribute. And If you try to get "offsetWidth" attribute, my app
> would suspend until I kill it.
Well, every attribute on an HTML element is reflected in a property
(usually of the same name, with class->className being the only
exception if I recall correctly). But not every property is reflected in
an attribute: e.g. you cannot write <span offsetWidth="123"> in an HTML
document (to be precise, you _can_ write that, but the attribute will
have no effect).
If you want to read any property given its name as a string, try using
late binding, via IDispatch::GetIdsOfNames and Invoke.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
date: Mon, 7 Jul 2008 08:04:22 -0400
author: Igor Tandetnik
Re: How to get dynamic attribute at runtime
On Jul 7, 8:04 pm, "Igor Tandetnik" wrote:
> wrote in message
>
> news:0130fe3d-e498-4906-be85-353e39dcd359@27g2000hsf.googlegroups.com
>
> > Yep. IHTMLElement::get_className really solves my problem. But I want
> > to know if there are any universal way to get the attributes. If I
> > have to write specific code to get sepcific attribute, my code would
> > be in a mess and difficult to maintain. I have tried IHTMLDOMAttribute
> > and IHTMLDOMAttribute2, the behavior of both are odd...It does works
> > with "class" attribute. But if I tried to get "align", my app crash. I
> > have not troubleshooted this, however, I could get "align" by
> > getAttribute. And If you try to get "offsetWidth" attribute, my app
> > would suspend until I kill it.
>
> Well, every attribute on an HTML element is reflected in a property
> (usually of the same name, with class->className being the only
> exception if I recall correctly). But not every property is reflected in
> an attribute: e.g. you cannot write <span offsetWidth="123"> in an HTML
> document (to be precise, you _can_ write that, but the attribute will
> have no effect).
>
> If you want to read any property given its name as a string, try using
> late binding, via IDispatch::GetIdsOfNames and Invoke.
Thanks...looks like my simple tool is going to get complicate...
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
date: Mon, 7 Jul 2008 18:52:39 -0700 (PDT)
author: unknown
|
|