mheavers mheavers - 5 months ago 12
jQuery Question

Javascript / Chrome - How to copy an object from the webkit inspector as code

I am doing a console.log statement in my javascript in order to log a javascript object. I'm wondering if there's a way, once that's done - to copy that object as javascript code. What I'm trying to do is convert an object that was created using ajax to parse an xml feed into a static javascript object so that a file can run locally, without a server. I've included a screenshot of the object in the chrome inspector window so you can see what I'm trying to do.enter image description here

Answer
  1. Right-click an object in Chrome's console and select Store as Global Variable. It will return something like temp1 as the variable name.

  2. Chrome also has a copy() method, so copy(temp1) in the console should copy that object to your clipboard.

Comments