continue with this topic.

I wrote some scripts to try to loop all objects in the browser (say,
firefox), and made it below :

{{{
<script type="text/javascript">

function Hashtable()
{
    this._hash = new Object();
    this.add = function(key,value){
        if(typeof(key)!= "undefined"){
            if(this.contains(key)==false){
                this._hash[key] = (typeof(value)=="undefined"?
null:value);
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
    this.remove = function(key){delete this._hash[key];}
    this.count = function(){var i=0;for(var k in this._hash){i++;}
return i;}
    this.items = function(key){return this._hash[key];}
    this.contains = function(key){return typeof(this._hash[key])!=
"undefined";}
    this.clear = function(){for(var k in this._hash){delete this._hash
[k];}}
    this.toString = function(){
        var str = [];
        for (var i in this._hash){ str.push(i.toString()); }
        return str.join("<br />");
    }
}

var vars = new Hashtable();
function takesnapshot()
{
    list = function(obj)
    {
        if(obj.toString() == 'vars') return; // exclude vars self.
        vars.add(obj.toString(), obj.toString());
        for(var p in obj) list(p);
    }
    list(window);
    // now, vars is a snapshot of window.
}

setTimeout(takesnapshot, 10);
setTimeout(function(){
        alert("vars len = " + vars.count());
        document.body.innerHTML = vars.toString();
}, 2000);

</script>
}}}

However, it didn't output what I wanted. Moreover, the output differed
between IE and firefox (or Chrome etc.)
Is it caused by the single threading implementations of javascript?
Thanks for any idea.

--

You received this message because you are subscribed to the Google Groups 
"Firebug" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/firebug?hl=en.


Reply via email to