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 各个部分的标点符号。

  • 相关阅读:
    java反射详解
    Oracle创建视图权限不足(解决)
    SQL Server为啥使用了这么多内存?
    在cmd中运行android.bat报出空指针异常
    QTP生成随机数字+字母
    loadView和ViewDidLoad区别
    Bonjour(苹果电脑公司的服务器搜索协议商标名)
    |= 或赋值
    我见过的类
    UML 继承和接口实现
  • 原文地址:https://www.cnblogs.com/zhangxiaolei521/p/5231559.html
Copyright © 2011-2022 走看看