小编Ton*_*bet的帖子

如何衡量jQuery代码的性能

我知道有些选择器比其他选择器更快,当然我们自己的方法可以更快或更慢.

是否有任何软件/应用程序可以分析CPU使用情况,甚至可以比较/基准测试版本?

benchmarking jquery

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

location.href = location.href不会重定向

在我的javascript代码中,在某些时候,我需要刷新窗口(用户已经上传了新图像,但在页面中仍然可以看到它)

我想知道为什么

location.href = location.href
Run Code Online (Sandbox Code Playgroud)

没有刷新窗户?

javascript jquery

4
推荐指数
2
解决办法
6272
查看次数

在jquery选择器路径中添加异常的最佳方法

假设我想绑定所有项目

#mainDiv .user
Run Code Online (Sandbox Code Playgroud)

除了

#mainDiv #exception .user
Run Code Online (Sandbox Code Playgroud)

我能想到

$('#mainDiv .user').bind('event',function(){
    if($(this).parents('#exception').length>0){}else{
       // do stuff;   
    }

});
Run Code Online (Sandbox Code Playgroud)

要么:

$('#mainDiv :not('#exception').find('.user').bind('event',function(){
    if($(this).parents('#exception').length>0){}else{
       // do stuff;   
    }

});
Run Code Online (Sandbox Code Playgroud)

什么是更好的?

jquery events css-selectors custom-exceptions

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

为什么我的网站可以"加载"两次?

或者至少这是pingdom所说的,我认为这是一项非常可靠的服务,

笔记:

  1. APACHE:php和mysql
  2. 没有iframe
  3. htaccess的:

    #Gzip
    <ifmodule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x- javascript application/javascript
    </ifmodule>
    #End Gzip
    
    
    # 480 weeks
    <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|css|swf)$">
    Header set Cache-Control "max-age=290304000, public"
    </FilesMatch>
    
    # 1 weeks
    <FilesMatch "\.(js)$">
    Header set Cache-Control "max-age=604800, public"
    </FilesMatch>
    
    RewriteEngine On
    
    
    ErrorDocument 500 /oohps.php
    ErrorDocument 404 /where.php
    
    
    RewriteCond %{HTTP_HOST} ^www.keepyourlinks.com [NC]
    RewriteRule ^(.*)$ http://keepyourlinks.com/$1 [L,R=301]
    
    RewriteCond %{HTTP_HOST} ^www.keepyourlinks.byethost32.com [NC]
    RewriteRule ^(.*)$ http://keepyourlinks.com/$1 [L,R=301]
    
    RewriteCond %{HTTP_HOST} ^keepyourlinks.byethost32.com [NC]
    RewriteRule ^(.*)$ http://keepyourlinks.com/$1 [L,R=301]
    
    RewriteCond %{HTTP_HOST} ^keepyourlinks.com/pre/ …
    Run Code Online (Sandbox Code Playgroud)

php apache load-time pingdom

4
推荐指数
2
解决办法
6363
查看次数

如何在CSS3中动画元素摆动?

自从我看到Treahouse网站和树上的标志效应摆动以来,我一直在努力重现它.

.box{
    width:50px; height:50px;
    background: blue;
    box-shadow: 0 0 5px blue;
    margin:100px;
    float: left;
    -moz-animation: 3s ease 0s normal none infinite swing;
    -moz-transform-origin: center top;
}
Run Code Online (Sandbox Code Playgroud)

但它不会摇摆.

这是JS Fiddle的演示.

我也试过修改它.

bod{
  background:blue;
}
.box{
    width:50px; height:50px;
    background: yellow;
    box-shadow: 0 0 10px red,0 0 25px red inset;
    margin:100px;
    float: left;
    -moz-animation: 3s ease 0s normal none infinite swing;
    -moz-transform-origin: center top;
    border-radius:50%;
}
@-webkit-keyframes swing {
 from {
   left: -2px;
 }
 to {
   left: 200px;
 } …
Run Code Online (Sandbox Code Playgroud)

css css3 css-animations

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

带有html2canvas的div的屏幕截图.发送到PHP,保存:损坏的图像

我生成画布并将其传递给php所以:

$('body').on('click','#save_image',function(){
                html2canvas($('.myImage'), {
                    onrendered: function(canvas) {
                        //$('.imageHolder').html(canvas);
                            var dataURL = canvas.toDataURL("image/png");

                           // $('.imageHolder').append('<img src="'+dataURL+'" />');
                            $('.imageHolder').html('Generating..');
                            $.post('image.php',{image: dataURL},function(data){
                                $('.imageHolder').html(data);
                            });
                    }
                });
 });
Run Code Online (Sandbox Code Playgroud)

image.php:

<?
    $image = $_POST['image'];
    echo "<img src='$image' alt='image' />";
    $decoded = str_replace('data:image/png;base64,','',$image);
    $name = time();
    file_put_contents("/home/toni005/public_html/toniweb.us/div2img/" . $name . ".png", $decoded);
    echo '<p><a href="download.php?img='.$name.'.png">Download</a></p>';
?>
Run Code Online (Sandbox Code Playgroud)

的download.php:

    <? $file = $_GET['img'];
header('Content-Description: File Transfer');
header("Content-type: image/jpg");
header("Content-disposition: attachment; filename= ".$file."");
readfile($file);
?>
Run Code Online (Sandbox Code Playgroud)

问题是生成图像,当我点击下载链接时,下载被伪造但图像无法打开(似乎已损坏)

我错过了什么?

它可以在这里测试:http://toniweb.us/div2img/

php base64 png html2canvas

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

使用Mail()类发送的电子邮件显示HTML代码,而不是结果

这是我如何使用opencart中的Mail()类发送电子邮件:

$mail = new Mail();
                $mail->protocol = $this->config->get('config_mail_protocol');
                $mail->parameter = $this->config->get('config_mail_parameter');
                $mail->hostname = $this->config->get('config_smtp_host');
                $mail->username = $this->config->get('config_smtp_username');
                $mail->password = $this->config->get('config_smtp_password');
                $mail->port = $this->config->get('config_smtp_port');
                $mail->timeout = $this->config->get('config_smtp_timeout');             
                //$mail->setTo($this->config->get('config_email'));
                //$mail->setFrom($this->request->post['email']);

                $mail->setTo('test1@test.com');
                $mail->setFrom('test@test.com');

                $mail->setSender($this->request->post['name']);
                $mail->setSubject(html_entity_decode('La reserva de tu alquiler ha sido correcta', ENT_QUOTES, 'UTF-8'));
                $mailText = '
                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                <html>
                    <head>
                        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                    </head>
                    <body>
                        <div class="confirmacion">
                            <h1>Su reseva se ha realizado  correctamente</h1>
                            <p> El pago del alquiler se hará en su …
Run Code Online (Sandbox Code Playgroud)

html php email opencart

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

像codeigniter for opencart的base_url?

Codeigniter有一个功能, base_url()

<?php echo base_url('/file')?>
Run Code Online (Sandbox Code Playgroud)

打印绝对URL,

Opencart有没有相应的东西?

php base-url opencart

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

无法安装我的自定义Chrome扩展程序crx_magic_number_invalid

我做了一个简单的chrome扩展:

manifest.json的:

{
  "name": "Layout VS Design",
  "version": "1",
  "description": "Enter the url of a image with your design at 100%",
  "background_page": "index.html",
  "browser_action": {
    "name": "Manipulate DOM",
    "icons": ["icon.png"],
    "default_icon": "icon.png"
  },
  "content_scripts": [ {
    "js": [ "jquery.min.js", "js.js" ],
    "matches": [ "http://*/*", "https://*/*"]
  }]
}
Run Code Online (Sandbox Code Playgroud)

问题是chrome不会让我安装它: 在此输入图像描述

问题是我不知道在哪里设置这个数字,不知道我能尝试什么?

google-chrome google-chrome-extension

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

如何合并 Google 字体导入

我正在使用带有 Divi 主题的 WordPress,

有这样的代码:

    function et_divi_fonts_url() {
    $fonts_url = '';

    /* Translators: If there are characters in your language that are not
     * supported by Open Sans, translate this to 'off'. Do not translate
     * into your own language.
     */
    $open_sans = _x( 'on', 'Open Sans font: on or off', 'Divi' );

    if ( 'off' !== $open_sans ) {
        $font_families = array();

        if ( 'off' !== $open_sans )
            $font_families[] = 'Open+Sans:300italic,400italic,700italic,800italic,400,300,700,800';

        $protocol = is_ssl() ? 'https' : 'http';
        $query_args …
Run Code Online (Sandbox Code Playgroud)

wordpress httprequest google-webfonts

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