ヒストリーの制御Control of history

historyの制御


定番の「戻る」リンク。
一つ前に見ていたページへジャンプします。
ボタンに組み込む場合は、onClickで指定。

<a href="javascript:history.back()"> 戻る </a>

<a href="javascript:history.go(-1)"> -1進む=戻る </a>

<input type=button onClick="history.back()" value=" 戻る ">



レアもの 「進む」リンク。
一つ先のページへジャンプします。go(x)の数値を変更すればx個前、x個先のページへジャンプさせる事もできます。利用価値はあまり無さそうだが…。

<a href="javascript:history.forward()"> 進む </a>

<a href="javascript:history.go(1)"> 進む </a>

<input type=button onClick="history.forward()" value=" 進む ">



どーでもいい「更新」リンク。
現在開いているページを更新します。

<a href="javascript:location.reload(true)"> 更新 </a>

<a href="javascript:history.go(0)"> 更新 </a>

<input type=button onClick="location.reload(true)" value=" 更新 ">



historyのURLをゲット
どこのページから来たかとか表示できますね。

window.history.current
window.history.next
window.history.previous




© 2004 maki All rights reserved.