小编gda*_*nko的帖子

无法让Chrome popup.js使用console.log

我在编写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调试器中.

javascript google-chrome-extension

41
推荐指数
1
解决办法
1万
查看次数

jstree类型插件不显示自定义图标

我有一个简单的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)

javascript jstree

10
推荐指数
3
解决办法
2万
查看次数

检查是否存在哈希密钥创建密钥

给出以下代码

#!/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}.这根本不符合逻辑.我所做的只是存在.我哪里做错了?

perl hash

6
推荐指数
1
解决办法
3178
查看次数

jsTree排序功能非常慢

我正在为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 jstree

6
推荐指数
1
解决办法
4852
查看次数

最初隐藏的Jquery创建元素

有没有办法创建一个元素并最初隐藏它?我正在创建一个iframe,但不希望它立即显示.

javascript jquery

5
推荐指数
2
解决办法
2万
查看次数

jquery keypress立即检索值

我想使用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 链接,你会看到我的问题所在.

javascript forms jquery

4
推荐指数
1
解决办法
1938
查看次数

在单个div上启用滚动?

我的布局看起来像这样:

<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的对话框?

html javascript css jquery jquery-ui

4
推荐指数
1
解决办法
1万
查看次数

我可以通过Perl确定给定的"主机名"是否为CNAME

在工作中,我有这样的事情......

$ 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记录等.

dns perl cname

4
推荐指数
1
解决办法
1777
查看次数

如果没有引用密钥,JSON :: XS会抱怨

我以这种格式取回JSON:

{key1:"value1", key2:"value2"} 
Run Code Online (Sandbox Code Playgroud)

如果我尝试使用JSON :: XS的decode_json方法为我转换它,但它抱怨没有引用键.我可以在JSON :: XS中设置一个选项来忽略这个怪癖吗?我查看了文档,但没有什么明显的.

perl json

2
推荐指数
1
解决办法
532
查看次数

在Perl中连接2个哈希时,我得到一个额外的元素"undef"

我有两个哈希,当我加入它们时,我得到一个额外的元素,"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来自哪里?

perl hash

1
推荐指数
1
解决办法
222
查看次数

标签 统计

javascript ×5

jquery ×4

perl ×4

hash ×2

jstree ×2

cname ×1

css ×1

dns ×1

forms ×1

google-chrome-extension ×1

html ×1

jquery-ui ×1

json ×1