時間経過によるページ遷移

サンプル

[[html]]
<style type="text/css">
@import url(http://scp-jp.wdfiles.com/local--files/japanese-syntax/scp-WikidotCss.css);
</style>
<script type="text/javascript" src="http://shitake-crude-production.wikidot.com/time-move/code/1"></script>
<script type="text/javascript">
function previewTime(argObj){
    var target = document.getElementById("times");
    target.innerHTML = addDigit(TimeRugMove.convert(argObj.rem,"sec",true),2) + ":" + addDigit(TimeRugMove.convert(argObj.rem,"msec",true),3);
    function addDigit(n,dn){
        n = String(n);
        while(n.length < dn){
            n = "0" + n;
        }
        return n;
    }
}
 
TimeRugMove.callback = previewTime;
TimeRugMove.time = 20;//20秒後に画面移動
TimeRugMove.url = "http://ja.scp-wiki.net/";//SCP財団に移動する
 
</script>
指定時間経過でSCP財団に遷移<br />
<button onclick="TimeRugMove.run();">start</button><br />
<button onclick="TimeRugMove.pause();">pause</button><br />
<button onclick="TimeRugMove.clear();">stop</button>
<div id="times">
</div>
[[/html]]

解説

<script type="text/javascript" src="http://shitake-crude-production.wikidot.com/time-move/code/1"></script>

をコードの上部にインポートすると

TimeRugMove

というオブジェクトが使えるようになります。

このオブジェクトに対し

TimeRugMove.time = 50;

で画面を遷移させたい経過時間

TimeRugMove.url = "http://ja.scp-wiki.net/";

で、遷移したい画面のURLを設定し、

TimeRugMove.run();

によって時間の計測および設定した時間以上が経過した場合の画面遷移を設定します。

なお、

TimeRugMove.callback

というプロパティに関数を渡す事によって時間計測中に作動させる関数を設定する事ができる。このプロパティに渡した関数内では現在の経過時間、及び画面遷移までの残り時間を取得する事ができます。

TimeRugMoveの仕様

下記ページをご覧ください。

時限式移動

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License