window.open()中的Ascii字符;

时间:2014-02-25 15:04:21

标签: javascript url

我正在尝试使用window.open();打开一个新窗口并将参数添加到URL的末尾。但是,当我输入花括号{}时,它会将其转换为十六进制代码(%7b和%7d)。

有谁知道如何以纯文本格式打印出来?

{!REQUIRESCRIPT("/soap/ajax/21.0/connection.js")}

sforce.connection.sessionId = '{!$Api.Session_ID}';

function errorMsg() {
    if (**field 1** == "") {
        return "Error please check all fields are completed";
    } else return "";
}

var error = errorMsg();
if (error != ''){
    alert(error);
    console.log('####' + error);
    } else if (error == ''){
    window.open("https://www.appextremes.com/apps/Conga/PointMerge.aspx?sessionId={!API.Session_ID}&serverUrl={!API.Partner_Server_URL_80}&id={!Opportunity.Id}&ESContactid={QVar0}","","width=700,height=450");
}

我尝试将花括号转换为通常接受的oct代码(\ 173),但我仍然得到相同的%7b输出:/

p.s我的实际代码和URL要长得多......我只是摆脱了垃圾,所以更容易阅读:)

提前感谢所有评论:)

2 个答案:

答案 0 :(得分:0)

虽然我希望你的代码可以工作,但你可以这样做:

window.open({!'" https://www.appextremes.com/apps/Conga/PointMerge.aspx?sessionId=' + API.Session_ID +' serverUrl =' + API.Partner_Server_URL_80 +' & id =' + Opportunity.Id +'& ESContactid =' + {Qvar0} +'","",&# 34;宽度= 700,高度= 450"'});

答案 1 :(得分:0)

感谢大家的意见,我已经解决了这个问题:)

我太傻了,事情太复杂了...... decodeURIComponent()

{!REQUIRESCRIPT("/soap/ajax/21.0/connection.js")}

sforce.connection.sessionId = '{!$Api.Session_ID}';

function errorMsg() {
    if (**field 1** == "") {
        return "Error please check all fields are completed";
    } else return "";
}

var error = errorMsg();

var URL = decodeURIComponent("https://www.appextremes.com/apps/Conga/PointMerge.aspx?sessionId={!API.Session_ID}&serverUrl={!API.Partner_Server_URL_80}&id={!Opportunity.Id}&ESContactid={QVar0}");

if (error != ''){
    alert(error);
    console.log('####' + error);
    } else if (error == ''){
    window.open(URL,"","width=700,height=450");
}