useful JS snippets

To see all direct properties and methods of an object (does not recurse):

function objinspect(obj){var s='';for(var e in obj)s+=e+':'+obj[e]+'n';opera.postError(s);}

Call it with the object you want to look at, for example objinspect(window); .

To emulate the document.load method in Opera:

        var doc=(document.implementation.createLSParser( document.implementation.MODE_SYNCHRONOUS, null )).parseURI(uri);
        this.appendChild(this.importNode(doc.documentElement, true));

BTW, why does Mozilla's document.load documentation claim that this method is from the DOM3 Load and Save spec when it isn't mentioned there?

To see all code that will be passed to eval() before evaluating it:

window.eval=(function(e){return function(s){opera.postError(s);return e(s);}})(window.eval);

2 thoughts on “useful JS snippets

  1. Um, "illegal use of eval" error. That's what I get for blogging *while* working rather than *after*. window.eval=window.alert; gets you only so far..

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s