| 目次 |
|---|
|
・attachEventの使い方 ・サンプル |
if(obj.attachEvent){
// IE用
}else{
// その他ブラウザ用
}
<script type="text/javascript">
window.onload = function() {
if(oButton1.attachEvent){
oButton1.attachEvent("onclick", dispMsg1, false);
oButton1.attachEvent("onclick", dispMsg2, false);
oButton2.attachEvent("onclick", dispMsg3, false);
}
}
function dispMsg1() {
alert("dispMsg1");
}
function dispMsg2() {
alert("dispMsg2");
}
function dispMsg3() {
alert(oButton2.attachEvent);
}
</script>
<input type="button" id="oButton1" value="ボタン" />
<input type="button" id="oButton2" value="確認ボタン" />