我有以下javascript代码,我将其用作书签。它工作得很好,但似乎我多次附加字符串'e?nooverride = 1'。我只想替换一次字符串。
以下是网址:https://c.cs24.visual.force.com/apex/page1?id=0061A00001386pX 这是所需的网址:https://c.cs24.visual.force.com/apex/page1?id=0061A00001386pX
这是我的代码:
var urlString = window.location.href;
if(urlString.includes("apex/page1?id=")){
urlString = urlString.replace("apex/page1?id=", "");
}
else if(urlString.includes("apex/page2?id=")){
urlString = urlString.replace("apex/page2?id=", "");
}
if(urlString.includes("&sfdc.override=1")){
urlString = urlString.replace("&sfdc.override=1", "");
}
window.location.href=urlString+'/e?nooverride=1';
答案 0 :(得分:0)
代码工作正常。我显然使用了后退/前进浏览器按钮,这弄乱了存储在网址中的内容。