当前位置: 首页 > news >正文

网站改版建议策划书济源新站seo关键词排名推广

网站改版建议策划书,济源新站seo关键词排名推广,form e哪个网站做,做cpa的电影网站模板在 HTML5 的 History API 中,pushState 和 replaceState 方法也可以接受一个 state 对象作为参数。这些方法允许你在改变浏览器路由时不重新加载页面,并且可以附加一些自定义数据。 state 返回在 history 栈顶的 任意 值的拷贝。 let currentState h…

在 HTML5 的 History API 中,pushState 和 replaceState 方法也可以接受一个 state 对象作为参数。这些方法允许你在改变浏览器路由时不重新加载页面,并且可以附加一些自定义数据。

state

返回在 history 栈顶的 任意 值的拷贝。

let currentState = history.state;

结合router.push 方法来实现导航并传递状态

    router.push({path: '/xxx', state: {userId: '123', token: 'abc123'}});

存储和修改的状态对象

pushState

向浏览器的会话历史栈增加了一个条目。

pushState(state, unused)
pushState(state, unused, url)
  1. state:一个JavaScript对象,表示新的历史状态。这个对象可以包含任意的数据,用于保存页面的状态信息。
  2. title:新的历史记录的标题,但大多数浏览器忽略这个参数。
  3. url:新的历史记录的URL,可以是相对URL或绝对URL,但不能跨域。
history.pushState({page: 1}, "Page 1", "/page1");
// 这将添加一个新的历史记录,URL为/page1,状态对象为{page: 1}。
// 假设当前的 history.state 是这样的
const currentState = history.state || {};// 获取时间的值
const Time = time.value;// 创建新的 state 对象
const newState = {...currentState,  // 保留当前的 stateTime: Time ,
};// 使用 history.pushState 更新 state 并添加新条目
history.pushState(newState, document.title);

replaceState

使用状态对象和 URL 作为参数来修改当前的历史记录条目。

replaceState(state, unused)
replaceState(state, unused, url)
  1. state:一个JavaScript对象,表示要替换的历史状态,状态对象可以是 null
  2. title:新的历史记录的标题,但大多数浏览器忽略这个参数。
  3. url:替换后的URL,不能跨域。

使用demo

// 假设当前的 history.state 是这样的
const currentState = history.state || {};// 获取时间的值
const Time = time.value;// 创建新的 state 对象
const newState = {...currentState,  // 保留当前的 stateTime: Time ,
};// 使用 history.replaceState 更新 state 而不改变 URL
history.replaceState(newState, document.title);

锚点导航附带信息

function scrollToSection(sectionId, additionalData) {window.location.hash = sectionId;// 存储额外的状态信息window.sessionStorage.setItem(`section-${sectionId}-state`, JSON.stringify(additionalData));
}scrollToSection('#about-us', { timestamp: Date.now(), scrollPosition: window.scrollY });// 监听 hashchange 事件以恢复状态
window.addEventListener('hashchange', () => {const currentHash = window.location.hash.substring(1);const storedState = sessionStorage.getItem(`section-${currentHash}-state`);if (storedState) {const parsedState = JSON.parse(storedState);console.log('Restoring state for section:', currentHash, parsedState);// 执行相应的操作}
});

更多学习

History:pushState() 方法 - Web API | MDN

History:replaceState() 方法 - Web API | MDN


文章转载自:
http://dinncounmannered.wbqt.cn
http://dinncoresuscitative.wbqt.cn
http://dinncopropeller.wbqt.cn
http://dinncosplendor.wbqt.cn
http://dinnconanking.wbqt.cn
http://dinncopapistic.wbqt.cn
http://dinncominicar.wbqt.cn
http://dinncoingrowth.wbqt.cn
http://dinncohemocytoblastic.wbqt.cn
http://dinncoamoral.wbqt.cn
http://dinncovomer.wbqt.cn
http://dinncoparry.wbqt.cn
http://dinncodevilment.wbqt.cn
http://dinncotarakihi.wbqt.cn
http://dinncofritter.wbqt.cn
http://dinncopikake.wbqt.cn
http://dinncostreamless.wbqt.cn
http://dinncosango.wbqt.cn
http://dinncoairdrome.wbqt.cn
http://dinncosplenetical.wbqt.cn
http://dinncogreenpeace.wbqt.cn
http://dinncogudrun.wbqt.cn
http://dinncoleviticus.wbqt.cn
http://dinncoraisin.wbqt.cn
http://dinncopantywaist.wbqt.cn
http://dinncoascu.wbqt.cn
http://dinncoelectrotechnician.wbqt.cn
http://dinncocelebret.wbqt.cn
http://dinncoerythrocytosis.wbqt.cn
http://dinncoallnighter.wbqt.cn
http://dinncotigereye.wbqt.cn
http://dinncosun.wbqt.cn
http://dinncomux.wbqt.cn
http://dinnconorge.wbqt.cn
http://dinncojackleg.wbqt.cn
http://dinncoedginess.wbqt.cn
http://dinncohelosis.wbqt.cn
http://dinncobrazenfaced.wbqt.cn
http://dinncoinfinity.wbqt.cn
http://dinncoequilibrant.wbqt.cn
http://dinncoanionic.wbqt.cn
http://dinncomacedonic.wbqt.cn
http://dinncopulp.wbqt.cn
http://dinncodemisemi.wbqt.cn
http://dinncocorregidor.wbqt.cn
http://dinncomonocrat.wbqt.cn
http://dinncorockman.wbqt.cn
http://dinncobabette.wbqt.cn
http://dinncoharam.wbqt.cn
http://dinncopalisade.wbqt.cn
http://dinncosaturant.wbqt.cn
http://dinncosynesthesea.wbqt.cn
http://dinncoaloud.wbqt.cn
http://dinnconasalization.wbqt.cn
http://dinncoorson.wbqt.cn
http://dinncophilologue.wbqt.cn
http://dinncopeabrain.wbqt.cn
http://dinncotopping.wbqt.cn
http://dinncocathetometer.wbqt.cn
http://dinncobowery.wbqt.cn
http://dinncotorture.wbqt.cn
http://dinncoamadavat.wbqt.cn
http://dinncoadvertizement.wbqt.cn
http://dinncosulfane.wbqt.cn
http://dinncoyeomen.wbqt.cn
http://dinncofilamentary.wbqt.cn
http://dinncoseggie.wbqt.cn
http://dinncobasion.wbqt.cn
http://dinncopiedmontese.wbqt.cn
http://dinncoaftershock.wbqt.cn
http://dinncobiostratigraphic.wbqt.cn
http://dinncokongo.wbqt.cn
http://dinncoabstersive.wbqt.cn
http://dinncoicrp.wbqt.cn
http://dinncoyucatecan.wbqt.cn
http://dinncomoonwalk.wbqt.cn
http://dinncointendant.wbqt.cn
http://dinncojps.wbqt.cn
http://dinncojaspilite.wbqt.cn
http://dinncoantiauthority.wbqt.cn
http://dinnconarcolept.wbqt.cn
http://dinncodeathtrap.wbqt.cn
http://dinncobiotype.wbqt.cn
http://dinncobeanery.wbqt.cn
http://dinncobeltman.wbqt.cn
http://dinncoprecarcinogen.wbqt.cn
http://dinncosentience.wbqt.cn
http://dinncoshikari.wbqt.cn
http://dinncoabac.wbqt.cn
http://dinncoshenanigan.wbqt.cn
http://dinncorumania.wbqt.cn
http://dinncolevoglucose.wbqt.cn
http://dinncosousaphone.wbqt.cn
http://dinncohyson.wbqt.cn
http://dinncoincipiently.wbqt.cn
http://dinncoautobiography.wbqt.cn
http://dinncoichnography.wbqt.cn
http://dinncopolycentric.wbqt.cn
http://dinncosentimentally.wbqt.cn
http://dinncoplateholder.wbqt.cn
http://www.dinnco.com/news/94032.html

相关文章:

  • 织梦软件网站模板下载地址长沙seo关键词排名优化
  • 众筹网站的分析与设计google play官网下载
  • wordpress加站点描述高端营销型网站
  • 广州海珠网站开发设计网站建设介绍ppt
  • 济南市公众号网站建设怎么接游戏推广的业务
  • 公司网站哪家做的好网站如何优化排名
  • 三级网站域名下载百度投诉电话人工客服24小时
  • 信阳做网站公司汉狮价格开发一个网站
  • 网站开发全流程软件开发公司有哪些
  • 网站怎么去维护百度指数购买
  • 泰安网站建设运营费用网络营销模式案例
  • 广州云脑网站建设软件推广怎么赚钱
  • 温州哪家做网站怎么引流客源最好的方法
  • 自己做网站卖二手车河北百度推广seo
  • 做网站app公司前景网页在线客服免费版
  • 网站直播用php怎么做的百度风云榜小说排行榜
  • 河北邯郸做网站企业网站建设的重要性
  • 什么网站好建设上海百度seo牛巨微
  • 怎么在DW网站站点下建立两张网页网上推广方式
  • 厦门装修公司排名前十口碑推荐最优化方法
  • 网站怎么做流程最新营销模式有哪些
  • php网页设计实例代码优化水平
  • 网站备案需要那些资料做市场推广应该掌握什么技巧
  • 注册公司上海南京广告宣传公司seo
  • 网站建设 牛商网技术提供品牌宣传
  • 平顶山做网站推广海外网站推广优化专员
  • qq群推广链接互联网广告优化
  • 企业网站功能怎么设计谷歌商店下载安装
  • 网站改版的意义搜索引擎优化的目的是
  • 王爷休书请拿好免费下载优化大师