How can I open the Google Chrome Console from JavaScript? [duplicate]

核能气质少年 提交于 2019-11-27 06:35:01

问题


The question might sound weird but I kind of need this to happen. The alternative would be to ask people to press Ctrl+Shift+i but I would prefer to avoid that and just provide a link.

The link would show up in a Chrome Extension so I'm only interested for Google Chrome.


回答1:


Sorry, not likely to happen (except as a security hole). Your in-page JavaScript is deliberately sandboxed and limited - it can interact with the page, and with the network through AJAX, but it cannot and should not interact with other things that happen in your computer - including the browser.




回答2:


It is not clear why you need to provide such link. DevTools is not a tool for the end user. If you don't like keyboard shortcuts, then there is a page chrome://inspect/ which has the list of pages and extensions, and each entry has a link that opens devtools.

Also, you may use remote debugging page which opens devtools in a page. https://developers.google.com/chrome-developer-tools/docs/remote-debugging




回答3:


Have you tried Firebug Lite. It is an in-browser tool similar to that found in Chrome.

http://getfirebug.com/firebuglite

It will give you most of the capabilities you are looking for (most likely), and will allow you to programmatically enable it and destroy it.

What do you think?



来源:https://stackoverflow.com/questions/4575134/how-can-i-open-the-google-chrome-console-from-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!