小编nym*_*ymo的帖子

带有空格和%的Javascript window.open url

我正在尝试window.open使用带空格的网址:

var msg = 'Hello, world!';  
var url = 'http://yoursite.com';  
var link = 'http://www.twitter.com/share?text=' + msg + '&url=' + url; 
window.open(link);
Run Code Online (Sandbox Code Playgroud)

运行此代码将打开一个新窗口http://twitter.com/share?text=Hello,%2520world!&url=http://yoursite.com.

会发生什么是msg中的空格转换为%20,然后'%'转换为%25.作为一种解决方法,我补充说:

msg = msg.replace(/\s/g, '+');

但是我需要注意其他字符还是有更好的解决方法?

javascript escaping spaces window.open

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

是否需要URL中的哈希引用代码?

其他网站的推荐程序生成带有哈希码的url来表示引用者.当网址发送给朋友和家人时,某些点或识别系统会奖励由哈希码定义的引用者...但为什么哈希码?为什么不是用户ID?

drupal referrals

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

如何在angularFire 0.5.0和最新的ng-grid之间创建3路数据绑定?

angularFire $ bind方法可以在这里找到:http://angularfire.com/flatdoc.html 和最新的ng-grid可以在这里找到:http://angular-ui.github.io/ng-grid/

我尝试了最简单的解决方案,但它没有用:

$scope.myData = [{name: "Moroni", age: 50},
                 {name: "Tiancum", age: 43},
                 {name: "Jacob", age: 27},
                 {name: "Nephi", age: 29},
                 {name: "Enos", age: 34}];
$scope.gridOptions = { 
    data: 'myData',

    rowTemplate:'<div ng-style="{\'cursor\': row.cursor, \'z-index\': col.zIndex(), \'color\': \'rgb(248, 248, 248)\',\'background\': \'none repeat scroll 0% 0% rgba(51, 51, 51, 0.7)\' }" ng-repeat="col in renderedColumns" ng-class="col.colIndex()" class="ngCell {{col.cellClass}}" ng-cell></div>',
    headerRowTemplate: '<div ng-style="{ height: col.headerRowHeight,\'color\': \'rgb(248, 248, 248)\',\'background\': \'none repeat scroll 0% 0% rgba(51, 51, 51, 0.7)\' …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs firebase ng-grid angularfire

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

具有简单条件的Angular js - ng-class =""将不起作用

嗨,我正在尝试通过一个元素添加一个类ng-class.如您所见,代码非常简单但不添加类:

app.run(function($rootScope, $location,$http,ngDialog,array_helper){
    var update =  function() {
        /*CONFIG PARAMS*/
        $rootScope.config = {};
        $rootScope.config.app_routes = [
            "/",
            "/channels",
            "/channels/create",
            "/users",
            "/auth/login",
            "/auth/signup"
        ];
        console.log($rootScope.config.app_url);
        console.log($rootScope.config.app_routes.indexOf($rootScope.config.app_url));
    };
    $rootScope.$on('$routeChangeStart', function() { 
        update(); 
    });
});
Run Code Online (Sandbox Code Playgroud)

然后在视图中,我做:

<div ng-view ng-animate class="" ng-class="{'slide': config.app_routes.indexOf(config.app_url) == -1}"></div>
Run Code Online (Sandbox Code Playgroud)

但似乎它永远不会起作用,因为它永远不会增加课程slide.同时console.log效果很好,只有在正确时才返回-1:O

javascript arrays view angularjs ng-class

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

PHP正则表达式:字符串必须包含字符类型

跟进PHP正则表达式以将字母数字字符串与某些(但不是全部)标点符号匹配,我必须接受至少2种类型的字符,这些字符必须是数字,字母或标点之一,而字符串必须介于长度为6和18个字符。这是最好的方法吗?我使用RegExLib的模式构造了此正则表达式。

preg_match('@' .  
// one number and one letter  
'^(?=.*\d)(?=.*[a-zA-Z])[!-%\'-?A-~]{6,18}$' .  
// one number and one punctuation  
'|^(?=.*\d)(?=.*[!-%\'-/:-?\[-`{-~])[!-%\'-?A-~]{6,18}$' .  
// or one punctation and one  
'|^(?=.*[!-%\'-/:-?\[-`{-~])(?=.*[a-zA-Z])[!-%\'-?A-~]{6,18}$' .  
'@i', $pass, $matches);
Run Code Online (Sandbox Code Playgroud)

php regex

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

为什么没有找到返回元素作为案例的关键?

在以下case语句中,x被设置为#\ j,但返回"bye".

(case (find #\j "joy") ((x) (princ "hi")) (otherwise (princ "bye")))
Run Code Online (Sandbox Code Playgroud)

find应该返回#\ j,它应该匹配x,对吧?

common-lisp

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