简体   繁体   English

如何将命令从文件传递到开发工具(例如Chrome开发工具)

[英]How pass command from file to dev-tools (ex chromium dev-tools)

I mean it, i want write a simple script in a .js file to execute in the console of the dev tools (with the dev tools API), for example is a use the $ sign in the simple .js file to pass to the dev- tools (script in a html page ) i get error : 我的意思是,我想在.js文件中编写一个简单脚本,以便在开发工具的控制台(使用dev工具API)中执行,例如,在简单.js文件中使用$符号传递给开发工具(HTML页面中的脚本)我得到了错误:

Uncaught ReferenceError: $ is not defined console.js:10
(anonymous function)

but in the dev-tools API, in the Chromium console it'll use to select the DOM element (selectByQuery()). 但是在dev-tools API中,在Chromium控制台中,它将用于选择DOM元素(selectByQuery())。

The problem is i can't understand how pass the script that it must be exec in the dev-tools console. 问题是我不明白如何在开发工具控制台中传递必须执行的脚本。 How can i solve this ? 我该如何解决?

Thanks in Advance 提前致谢

look at example how load jquery library. 看示例如何加载jquery库。 Just execute this in console. 只需在控制台中执行即可。 You can do similar with any script you need. 您可以对所需的任何脚本执行类似的操作。

var script = document.createElement( 'script' );
script.type = 'text/javascript';
script.src = '//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js';
document.body.appendChild(script);

Hope, i understood you right 希望我对你理解正确

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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