admin管理员组文章数量:1296459
I would like to debug bookmarklets. How can I do this? Preferably in Firefox.
Bookmarklets has only one line of code so direct debugging them is impracticable.
If I create "script" tag with code which I send from bookmarklet, code from this "script" tag isn't listed on Firebug scripts... (this code run properly, only can't debugging)
Alternatively, If there is a possibility to debug code typed in a console, it will be OK too.
I would like to debug bookmarklets. How can I do this? Preferably in Firefox.
Bookmarklets has only one line of code so direct debugging them is impracticable.
If I create "script" tag with code which I send from bookmarklet, code from this "script" tag isn't listed on Firebug scripts... (this code run properly, only can't debugging)
Alternatively, If there is a possibility to debug code typed in a console, it will be OK too.
Share Improve this question asked Mar 11, 2013 at 17:30 GreckGreck 5906 silver badges16 bronze badges3 Answers
Reset to default 4Make a bookmarklet like this:
javascript:document.body.appendChild(document.createElement('script')).setAttribute('src','http://localhost/test.js');void(0);
It would automatically appear in Firebug, as simple as that. (Assuming you have recent versions of Firefox and Firebug)
Use you development version of code in the test.js
file and use debugger;
or insert the breakpoints manually.
Extra note: If you face problems like your code works in development mode (by including file as mentioned above) but does not work when it is converted to a single line bookmarklet, then there must be a problem in the conversion/encoding you did to make it single line.
Paste your bookmarklet into the developer console, but before you execute it, add a debugger;
statement on the first line. The bookmarklet will appear in the debugger under a tab called "SOURCE".
copy & paste your bookmarklet code into the debugger console, press 'enter'
by "code" I mean
function(){ ... }();
any loaded javascript files will appear in the debugger tab, where you can set breakpoints, step through etc. when you paste (or up arrow in console) and press 'enter' a second time.
本文标签: javascriptDebugging bookmarklets in FirefoxStack Overflow
版权声明:本文标题:javascript - Debugging bookmarklets in Firefox - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741638013a2389750.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论