开发者

Check if an object is an element on google desktop

In javascript on a browser, I can do this to see if an object is DOM-related:

obj in开发者_运维问答stanceof Node

How do I accomplish this with google desktop? Node is undefined, and this doesn't work either:

obj instanceof basicElement


I'm not a Google Desktop expert, I just had a little time on my hands! From the documentation basicElement itself is never instantiated; it just provides a set of common properties and events for its descendant UI objects.

Therefore it looks like a JavaScript object will never be an instanceof basicElement.

However, you can always check to see if the JavaScript object implements one of basicElements more obscure method or property names - this should give you a reasonable indication that the object you are working with is a basicElement. Using something like this:

if((obj != 'undefined') && (obj != null) && ("hitTest" in obj)){
    alert('Probably implements basicElement');
} else {
    alert('Not a basicElement');
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜