Home > SYS_Window > urlReplaceState
SYS_Window.urlReplaceState() method
Modify the current URL history stack information
Signature
typescript
function urlReplaceState(url: string): void;1
Parameters
Parameter | Type | Description |
|---|---|---|
url | string | URL |
Returns
void
Example
javascript
// 1. 备份当前完整地址
const originalHref = location.href;
// 2. 把当前历史记录的地址改写为带示例锚点的地址
eda.sys_Window.urlReplaceState(`${location.href.split('#')[0]}#嘉立创示例_替换状态`);
// 3. 验证改写生效(getUrlAnchor 返回编码后的锚点,解码后展示)
console.log('改写后的锚点:', decodeURIComponent(eda.sys_Window.getUrlAnchor()));
// 4. 改回原地址(replaceState 不新增历史记录,此处完全还原)
eda.sys_Window.urlReplaceState(originalHref);
console.log('地址已还原');1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12