小编Ale*_*xis的帖子

在Android上下载APK时的文件名

当我从我的网络服务器上下载Android手机上的文件时,将其保存为

 downloadfile.apk
Run Code Online (Sandbox Code Playgroud)

该文件作为MyApp.apk保存在我的服务器上

你知道如何在Android的下载文件列表中将文件显示为MyApp.apk吗?

我还要提一下,为了让文件下载并被手机理解我修改了服务器上的.htaccess文件

 AddType application/vnd.android.package-archive apk
 DirectoryIndex MyApp.apk
Run Code Online (Sandbox Code Playgroud)

.htaccess android download apk

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

localStorage的"存储"事件中未定义的属性

更改localStorage时应该触发的事件似乎缺少Firefox中的信息.

我设置了以下事件处理程序:

 function storageEventHandler(e){
      alert("key " + e.key);
      alert("oldValue " + e.oldValue);
      alert("newValue " + e.newValue);
      alert("url " + e.url);
 }

 window.addEventListener('storage', storageEventHandler, false);
Run Code Online (Sandbox Code Playgroud)

应由此触发:

localStorage.setItem('foo', 'bar');

但是,事件中的所有属性(例如e.key和其他所有属性)都是未定义的.我正在使用Firefox 3.16.为什么事件属性未定义?

编辑.这是我正在使用的所有代码.存储事件在Firefox 3.16中触发,但在Firefox 4.0b8中不触发

此外,重要的是,我从XAMPP运行它http://localhost/index.html 从file运行它://使它死于localStorage获取NULL?

<!DOCTYPE html5>
<html lang="en">
<head>
    <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script>
        $(function() {
            var edit = document.getElementById('edit');

            $(edit).blur(function() {
                localStorage.setItem('todoData', this.innerHTML);
            });

            // when the page loads
            if (localStorage.getItem('todoData')) {
                edit.innerHTML = localStorage.getItem('todoData');
            }

            window.addEventListener('storage', storageEventHandler, false);

            function storageEventHandler(e){
                alert('localStorage event fired')
            } 
        });
    </script>
</head> …
Run Code Online (Sandbox Code Playgroud)

javascript html5 javascript-events local-storage

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

使用jQuery预加载图像,因此没有闪烁

我试图用jQuery在两个图像之间淡入淡出.第一次当图像交叉褪色时第一次出现眨眼的时候.所以我尝试在淡入淡出之前预先加载图像.然而,仍然有一个眨眼.下面是一个代码的简化示例,即使使用预加载的图像仍然闪烁(您应该能够复制并粘贴它并使其"正常工作"以查看问题).我怎么做才能没有眨眼?谢谢!

<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript">                                         

$(document).ready(function(){
    function preload(arrayOfImages) {
        var temp = $('<img>')
        temp.attr("src", "http://www.colorcombos.com/images/colors/hex-codes/FF9900.png")
        $('#myGallery').prepend(temp)

        var temp = $('<img>')
        temp.attr("src", "http://www.colorcombos.com/images/colors/hex-codes/003366.png")
        temp.attr("class", "active")
        $('#myGallery').prepend(temp)

        $(arrayOfImages).each(function(){
        });
    }

    preload();

    $('#switch').click(function(){
        swapImages()
    });

    function swapImages(){
        var $active = $('#myGallery .active');
        var $next = ($('#myGallery .active').next().length > 0) ? $('#myGallery .active').next() : $('#myGallery img:first');
        $active.fadeOut("fast")
        $active.removeClass('active')
        $next.fadeIn("fast").addClass('active');
    }

});

</script>

<style>
    #myGallery{
      position:relative;
      width:100px;
      height:100px;
    }

    #myGallery img{
      display:none;
      position:absolute;
      top:0;
      left:0;
    }

    #myGallery img.active{
      display:block;
    }
</style>

</head> …
Run Code Online (Sandbox Code Playgroud)

javascript jquery jquery-selectors

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

CoffeeScript中的变量类型

我不太确定CoffeeScript中不同变量的用途

class Cow
  @utters = 1

  constructor: (@name) ->

  mutate:->
     alert @utters

  heads: 1
  feet = 9


c = new Cow 
Run Code Online (Sandbox Code Playgroud)

从我的调查来看,这似乎heads是公开的,feet是私人的.在搞清楚时name,我会感到困惑utters.因为name它或多或少地编译this.name = name并为utters它编译Cow.utters = 1.

所以我的问题是.它的范围utters和方式应该是什么?它的范围name和方式应该是什么?

scope coffeescript

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

CoffeeScript中的多个回调

我试图找出正确的行为,将多个回调串起来.

class Person

  move_head: ->
     head.animate({
        left: x,
     },{
        complete: @move_foot,
     });

  move_foot: ->
     foot.animate({
        left: x,
     },{
        complete: @move_arm,
     });

  move_arm: ->
     arm.animate({
        left: x,
     },{
        complete: something_else,
     });
Run Code Online (Sandbox Code Playgroud)

现在的问题是,头部动画很好,这称之为脚.脚也很好动画.问题是当脚完成时,它不会使手臂动起来.我无法弄清楚问题可能是什么.我猜测它可能与范围问题有关.

javascript jquery coffeescript

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

Redis中的"存档"发布/订阅消息

我正在使用Redis的发布/订阅功能.因此,服务器发布10个项目,然后客户端获取这10个项目.

然而,现在,新客户订阅了订阅源.我希望他们能够获得前10个项目以及任何新项目.

Redis是否有办法使用发布和订阅功能?源记录是否存储在数据库中的任何位置?有这么简单的方法吗?是将邮件存储在列表中并让客户端LRANGE my_list 0 10在列表中执行操作的最佳方法吗?

redis node-redis

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