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

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

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744726169a4590190.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信