PR

CakePHPでbody onloadを使う

◆通常は以下のようになる

<body onLoad=”document.form1.field1.focus()”>

◆CakePHPではどうしたらよいか

スポンサードリンク

◇HTML(例)

<script type=”text/javascript” src=”message.js”></script>
<form method=”post” action=”index.php”>   
<input type=”text” name=”name” id=”name”>   
<input type=”submit” value=”submit”>   
</form>  

◇jsファイル(例)

window.onload = function() {
alert(“JavaScript”);
}

◆参考

tmp = document.getElementById(“mid”);

tmp = document.getElementsByName(“mid”)[0];

◆参考文献

コメント