zoukankan      html  css  js  c++  java
  • js中的encodeURIComponent()函数

    encodeURIComponent() 函数可把字符串作为 URI 组件进行编码。

    $scope.linktotheme = function () {
    if ($scope.curthemeid == null) return;
    $("#settings").modal('hide');
    var tempurl = "";
    var strceshi = $("#images").attr("imagelist").replace("iopcmd=convert&dst=jpg&Q=70|", "");
    var imagesstr = strceshi.replace("iopcmd=convert&dst=jpg&Q=70|", "");
    var imagesstr1 = imagesstr.replace("iopcmd=convert&dst=jpg&Q=70|", "");
    var imagesstr2 = imagesstr1.replace("iopcmd=convert&dst=jpg&Q=70|", "");
    var imagesstr3 = imagesstr2.replace("|iopcmd=convert&dst=jpg&Q=70", "");
    switch (typesign) {
    case 0:
    tempurl = "/hoteltheme/theme" + $scope.curthemeid + "?bgcolor=" + $scope.curcolor.substring(1, 7) + "&themeid=" + $scope.curthemeid;
    break;
    case 1:
    tempurl = "/hoteltheme/theme" + $scope.curthemeid + "?themeid=" + $scope.curthemeid;
    break;
    case 2:
    tempurl = "/hoteltheme/theme" + $scope.curthemeid + "?bgimgs=" + encodeURIComponent(imagesstr3) + "&themeid=" + $scope.curthemeid;
    break;
    case 3:
    tempurl = "/hoteltheme/theme" + $scope.curthemeid + "?themeid=" + $scope.curthemeid;
    break;
    }
    $location.url(tempurl);
    };

    请注意 encodeURIComponent() 函数 与 encodeURI() 函数的区别之处,前者假定它的参数是 URI 的一部分(比如协议、主机名、路径或查询字符串)。因此 encodeURIComponent() 函数将转义用于分隔 URI 各个部分的标点符号。

  • 相关阅读:
    php防止刷流量攻击
    PHP序列化变量的4种方法
    php递归操作目录 递归对参数转义
    php 图像裁剪(自定义裁剪图片大小)
    jquery实现点击文字后变成文本框且可修改
    mysql查看表注释和字段注释的方法
    php 获取中文字符串首字母
    Nginx.conf配置
    光盘作为yum源
    win7下安装mongodb
  • 原文地址:https://www.cnblogs.com/zhangxiaolei521/p/5231559.html
Copyright © 2011-2022 走看看