Adsense

Accessing a variable outside of a javascript function?



    function CrossDomainStorage() {}
  
    CrossDomainStorage.prototype = {
    foo: function(callback) {
    callback.call(this, 1, 'bar');
    }
    }
  
    var remoteStorage = new CrossDomainStorage;
  
    remoteStorage.foo(function(key, value) {
    alert('inside ' + value);
    this.val = value;
    });
  
    alert('outside ' + remoteStorage.val);

No comments:

Post a Comment

comment here

newest questions on wordpress