我在编写JS时大量使用console.log进行调试.我正在尝试使用它来编写chrome扩展,但它无法正常工作.这里有一些诡计吗?
popup.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link type="text/css" rel="stylesheet" href="css/jquery-ui-1.10.0.custom.min.css" />
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.10.0.custom.min.js"></script>
<script type="text/javascript" src="js/popup.js"></script>
</head>
<body style="width: 200px">
</body>
Run Code Online (Sandbox Code Playgroud)
popup.js
console.log('test1');
$(document).ready(function() {
console.log('test2');
});
Run Code Online (Sandbox Code Playgroud)
这些都不会出现在JS调试器中.
我有一个简单的HTML布局,如下所示:
<div id="foo">
<ul>
<li id="id1"><a href="#">some category 1</a>
<ul><li><a href="#">some text</a></li></ul>
<ul><li><a href="#">some text</a></li></ul>
</li>
<li id="id2"><a href="#">some category 2</a>
<ul><li><a href="#">some text</a></li></ul>
<ul><li><a href="#">some text</a></li></ul>
</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
jstree定义看起来像这样
$('#foo').jstree({
"core" : {
"animation" : 0
},
"themes" : {
"theme" : "classic",
"dots" : false,
"icons" : true
},
"sort" : function (a, b) {
return this.get_text(a) > this.get_text(b) ? 1 : -1;
},
"types" : {
"valid_children" : [ "folder" ],
"types" : {
"folder" : …
Run Code Online (Sandbox Code Playgroud) 给出以下代码
#!/usr/bin/perl
use Data::Dumper;
my %hash;
my @colos = qw(ac4 ch1 ir2 ird kr3);
foreach my $colo (@colos) {
if(exists $hash{output}{$colo}) {
print "$colo is in the hash\n";
}
}
print Dumper(\%hash);
Run Code Online (Sandbox Code Playgroud)
我有一个空哈希创建.我有一个数组,里面有几个缩写.如果我遍历数组以查看这些人是否在哈希中,则没有任何内容显示给STDOUT,这是预期的但是由于某种原因创建了$ hash {output}.这根本不符合逻辑.我所做的只是存在.我哪里做错了?
我正在为Delicious书签撰写Chrome扩展程序.我的background.js文件在浏览器打开时获取书签,并创建jsTree构建正确树所需的对象.
如果我禁用jsTree的排序插件,单击弹出窗口时会立即显示书签.如果启用排序功能,则单击和显示数据之间会有约2秒的延迟.
我尝试在后台脚本中对所有数据进行预先排序,并将其传递给预先排序的弹出窗口,但jsTree不支持此排序数据.
我只有~90个标签和~400个书签.有没有配置选项,我可以使用它来加快速度?这是我的jsTree的样子.
$('#jstree').jstree({
'close_all': -1,
'core': {
'animation': 0
},
'json_data': {
'async': true,
'data': data
},
'progressive_render': true,
'themes': {
'theme': 'classic',
'dots': false,
'icons': true
},
'sort': function (a, b) {
return this.get_text(a) > this.get_text(b) ? 1 : -1;
},
'types': {
'valid_children': [ 'folder' ],
'types': {
'folder': {
'valid_children': [ 'file' ],
'max_depth': 1
},
}
},
'plugins': [
'json_data',
'themes',
'sort',
'types',
]
});
Run Code Online (Sandbox Code Playgroud) 我想使用jquery.keypress获取输入框的内容,我在这里看到了答案 .但这并不是我需要的.
HTML看起来像这样:
<input type="text" id="foo" size="15" maxlength="50">
Run Code Online (Sandbox Code Playgroud)
jquery代码如下所示:
$("#foo").keypress (function (e) {
alert ($(this).val());
});
Run Code Online (Sandbox Code Playgroud)
所以现在我有一个输入框.我输入"a".我的警报是空白的,因为处理程序正在检索'#foo'的PREVIOUS内容.现在如果我输入'b',警报将有"a"而不是"ab"等等.看看这个jsfiddle 链接,你会看到我的问题所在.
我的布局看起来像这样:
<html>
<head>
stuff here
</head>
<body>
<div id="master">
<div id="toolbar">
<input type="text" id="foo">
</div>
<div id="content">
a whole bunch of content in here
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
'#master'是jquery UI对话框的容器.我希望'#content'div的内容可以滚动,但'#toolbar'不能滚动.这是否适用于jquery UI的对话框?
在工作中,我有这样的事情......
$ host www.something.com
www.something.com is an alias for some.other.address
some.other.address is an alias for one.more.address
one.more.address has address xxx.xxx.xxx.xxx
Run Code Online (Sandbox Code Playgroud)
我想要一种方法,在Perl中输入www.something.com
并确定它是否是CNAME,A记录等.
我以这种格式取回JSON:
{key1:"value1", key2:"value2"}
Run Code Online (Sandbox Code Playgroud)
如果我尝试使用JSON :: XS的decode_json方法为我转换它,但它抱怨没有引用键.我可以在JSON :: XS中设置一个选项来忽略这个怪癖吗?我查看了文档,但没有什么明显的.
我有两个哈希,当我加入它们时,我得到一个额外的元素,"undef".为什么?
#!/usr/bin/perl
use Data::Dumper;
my %foo = (
"disable-notify",
"start=s",
"end=s"
);
test();
sub test() {
my %bar = (
"notify-disabled",
"durtion=s",
"help",
"my-stuff"
);
my %poop = (%foo, %bar);
print Dumper(%poop);
}
Run Code Online (Sandbox Code Playgroud)
运行代码给了我:
$VAR1 = 'notify-disabled';
$VAR2 = 'durtion=s';
$VAR3 = 'help';
$VAR4 = 'my-stuff';
$VAR5 = 'disable-notify';
$VAR6 = 'start=s';
$VAR7 = 'end=s';
$VAR8 = undef;
Run Code Online (Sandbox Code Playgroud)
这个undef来自哪里?