Javascriptをはじめ、Ajax、jQueryの著書多数のガイドが、何かと最近騒がれているJa…
Javascript関連情報
更新日:2008年07月19日
今回から特別に、今月(2008年7月11日)発売されたばかりの話題の携帯 iPhone 3G 用にWebページを作る際のポイントをみてみます。今回は、ユーザーエージェントの確認とビューポートです。
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport"
content="width=320; initial-scale=1.0; user-scalable=0;">
</head>
<body>
<div>
<button onclick="alert('alert()です')">alert()</button>
<button onclick="confirm('confirm()です。')">confirm()</button>
<button onclick="prompt('prompt()です')">prompt()</button>
</div>
</body>
</html>
各ボタンをクリックします。 |
alert() : 普通のalertダイアログです。 |
confirm() : これも普通のconfirmです。 |
prompt() : ダイアログ表示と同時に入力可能な状態になります |
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="content-script-type" content="text/javascript">
<meta http-equiv="content-style-type" content="text/css">
<meta name="viewport"
content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<script src="./test.js" type="text/javascript"></script>
</head>
<body>
<div>
<button id="ale">alert()</button>
<button id="con">confirm()</button>
<button id="pro">prompt()</button>
</div>
</body>
</html>
window.addEventListener("load", function(event){
var ale = document.getElementById("ale"),
con = document.getElementById("con"),
pro = document.getElementById("pro")
ale.addEventListener("click", function(event){
alert('alert()です');
}, false);
con.addEventListener("click", function(event){
confirm('confirm()です');
}, false);
pro.addEventListener("click", function(event){
prompt('prompt()です');
}, false);
}, false);
人気Javascriptランキング
Powered by 価格.com