how to use local javascript files to test on live site using firebug (or Chrome)?
I've got some custom JS that i'm looking to deploy on a live site, but I want to test it out first.
I'm a third-party consultant to the target site managers, and am not part of their build process, so I can't deploy in their test environments. Since it's a DOM traversal library, it's pretty specific.
I was wondering if anyone knew how to get my local javascript files to auto-insert f开发者_如何学编程or a particular domain or host.
Thanks!
Why not just inject the script you're working on in firebug's console:
var script = document.createElement('script');
script.src = 'url to local file';
document.appendChild(script);
Or if you have jQuery
$.getScript('url to script file.js');
Install Greasemonkey Add-On for Firefox.
This Add-On can inject Javascript for pages with certain URLs matching a regex given in the injected JS-file.
If you want to learn how others are writing their Greasemonkey-Scripts then search for FF Add-Ons that start with "BetterXYZ" like BetterGmail, BetterFacebook, BetterGoogle ... Greasemonkey-Skripts are in fact Javascript-Files with special initial JS-Comment and a special file extension "*.user.js".
精彩评论