Claudiu
Claudiu

Reputation: 229361

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 instanceof Node

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

obj instanceof basicElement

Upvotes: 2

Views: 154

Answers (1)

Mark McLaren
Mark McLaren

Reputation: 11540

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');
}

Upvotes: 1

Related Questions