我可以使用Chrome开发工具添加资源吗? [英] Can I add a resource using Chrome Dev Tools?

查看:118
本文介绍了我可以使用Chrome开发工具添加资源吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Chrome浏览器查看网页。原始源代码不包含jQuery,但使用一些jQuery函数检查DOM会非常有帮助。将源代码改为包含jQuery脚本是一种痛苦,因此是否可以在页面加载后使用Chrome开发工具将jQuery加载到DOM?或者,是否存在原生JavaScript函数可以执行加载?我试图编辑head标签以包含< script src = /path/to/jQuery.min.js\"></script> 标记,但实际上并未加载jQuery.min.js文件。



不幸的是,Modernizr和其他资产加载程序也未包含在源代码中。 能够在你的JS控制台中运行。

  var jq = document.createElement('script'); 
jq.src =/path/to/jQuery.min.js;
document.getElementsByTagName('head')[0] .appendChild(jq);
jQuery.noConflict();

您也可以复制整个 jQuery文件进入控制台。不是最好的选择,但也可以。



第三个选项是这个插件 jQueryify ,我自己并没有使用它,但看起来很有希望。


I'm viewing a webpage using Chrome. The original source does not include jQuery, but it'd be really helpful to use some jQuery functions to inspect the DOM. It would be a pain to alter the source to include the jQuery script, so is it possible to use Chrome Developer Tools to load jQuery to the DOM after the page loads? Alternately, is there a native JavaScript function that could perform the load?

I tried to edit the head tag to include the <script src="/path/to/jQuery.min.js"></script> tag, but that doesn't actually load the jQuery.min.js file.

Unfortunately, Modernizr and other asset loaders are also not included with the source.

解决方案

You should be able to run this in your JS console.

var jq = document.createElement('script');
jq.src = "/path/to/jQuery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
jQuery.noConflict();

Alternatively you can copy the entire jQuery file into the console. Not the best option, but that would work too.

A third option is this plugin, jQueryify, I haven't used it myself, but looks promising.

这篇关于我可以使用Chrome开发工具添加资源吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆