简体   繁体   中英

Chrome Debugging Chrome Extension Javascript

I am trying to debug a chrome extension. I have opened up the background page in the extension page but I was wondering if there was a way to look at the array type that I have.

For example, I have the code

function main() {
var cells = document.getElementsByClassName('sectionFieldInstructor');
var length = cells.length;
var professors = [];
var profCount = 0;

Where my cells is the teachers in the list. I would like to view which teachers I have in the cells array.

Also, in the inspected page, the teachers name is listed as

<a href="search?mode=search&instructor=TEACHER">A. TEACHER</a><br/>

Would it be affected by that?

Thanks!

You can do that with Chrome developer tools. The easiset way is to add

var cells = document.getElementsByClassName('sectionFieldInstructor');    
    console.log(cells); //Add this line     
var length = cells.length;

Then it will be displayed in your console. (There is a tab in dev tools called console.)

You can call that function from the console as well by typing:

main();

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM