prototype.js HTMLとスクリプトを分離
以下のようなスクリプトを、HTML側で読み込む。
<script type="text/javascript" src="/js/hoge.js"></script>
hoge.js
// Window のロード時に initDocumentを呼び出す Event.observe(window, 'load', initDocument, false); // 初期処理 function initDocument() { setEventHundler(); } // イベントハンドラをセット function setEventHundler() { Event.observe($('elmt1'), 'click', hndler1, false); Event.observe($('elmt2'), 'click', hndler2, false); } // イベントハンドラ1 function hndler1() { } // イベントハンドラ2 function hndler2() { }
YAGI Hiroto (piroto@a-net.email.ne.jp)
twitter http://twitter.com/pppiroto
Copyright© 矢木 浩人 All Rights Reserved.