最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to use first parameter in history.pushstate - Stack Overflow

programmeradmin0浏览0评论

After reading and playing around with history.api I am wondering how to use first parameter in

history.pushState(stateObj, title, url);

I understand that stateObj is a js object so something like this:

{
  par1 : 'par1',
  par2 : 2
}

But how I have to use it? What method gives me the possibility to retrieve this object later.

I also understood that title is not used right now and I have to use my own javascript methods to change the title of the page. Am I right?

After reading https://developer.mozilla/en-US/docs/DOM/Manipulating_the_browser_history and playing around with history.api I am wondering how to use first parameter in

history.pushState(stateObj, title, url);

I understand that stateObj is a js object so something like this:

{
  par1 : 'par1',
  par2 : 2
}

But how I have to use it? What method gives me the possibility to retrieve this object later.

I also understood that title is not used right now and I have to use my own javascript methods to change the title of the page. Am I right?

Share Improve this question asked Nov 12, 2012 at 1:02 user1015104user1015104
Add a ment  | 

1 Answer 1

Reset to default 6

It is extremely easy: all you have to do is:

history.pushState({
  par1 : 'par1',
  par2 : 2
}, '', 'url');

To get this object you have to do

var tmp = history.state;

tmp will be equal to

{
    par1 : 'par1',
    par2 : 2
}

Regarding the second question. As far as I know - you are right. For example you can send your title in that object, you were asking in the first question.

发布评论

评论列表(0)

  1. 暂无评论