[PR]
×
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
×
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
var stateObj = {'type':'A'};
history.pushState(stateObj,"Page 1", "/page1");
<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript">
function clickPage1(){
history.pushState({'type':'A'}, "Page 1", "/page1");
}
function clickPage2(){
history.pushState({'type':'B'}, "Page 2", "/page2");
}
window.onpopstate = function(e){
var currentState = history.state;
console.log(e.state);
console.log(currentState);
};
</script>
</head>
<body>
<br />
<button class="page1" onclick="clickPage1()">page1</button>
<button class="page2" onclick="clickPage2()">page2</button>
</body>
</html>
上記の例ではcurrentStateまたはe.stateがpushStateで入力したオブジェクトを返してくれる。・・・
// Bind to StateChange Event
History.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate
var State = History.getState(); // Note: We are using History.getState() instead of event.state
History.log(State.data, State.title, State.url);
});
・・・
var stateObj = {'type':'A'};
history.pushState(stateObj,"Page 1", "/page1");
<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript">
function clickPage1(){
history.pushState({'type':'A'}, "Page 1", "/page1");
}
function clickPage2(){
history.pushState({'type':'B'}, "Page 2", "/page2");
}
window.onpopstate = function(e){
var currentState = history.state;
console.log(e.state);
console.log(currentState);
};
</script>
</head>
<body>
<br />
<button class="page1" onclick="clickPage1()">page1</button>
<button class="page2" onclick="clickPage2()">page2</button>
</body>
</html>
上記の例ではcurrentStateまたはe.stateがpushStateで入力したオブジェクトを返してくれる。・・・
// Bind to StateChange Event
History.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate
var State = History.getState(); // Note: We are using History.getState() instead of event.state
History.log(State.data, State.title, State.url);
});
・・・