首页 > 代码库 > JavaScriptの例

JavaScriptの例

Dateのオブジェクト:

<html>
<head>
<title>Date Object Example</title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
days=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday");
today=new Date
document.write("Today is "+days[today.getDay()]);
</script>
</body>
</head>
</html>

 

日付のチェック:

<html>
<head>
<title>Validation Program</title>
<script type="text/javascript">
function validateNumber(tForm){
    if(tForm.result.value !=5){
        this.alert ("Not 5!");
    }else{
        this.alert("Correct.Good Job!");
    }
}
</script>
</head>
<body>
<hr>
<p>
<h1>Validate</h1>
<form name="form">
<input type="text" name="result" value="http://www.mamicode.com/0" SIZE="2">
<input type="button" value="http://www.mamicode.com/Validate" name="calcButton"
onClick="validateNumber(this.form)">
</form>
<hr>
</body>
</html>

失敗の例:

<html>
<head>
<title>Slider</title>
</head>
<body>

<object classid="clsid:F08DF954-8592-11D1-B16A-00C0F0283628" id="Slider1" width="100" height="50">
<param name="BorderStyle" value="http://www.mamicode.com/1"/>
<param name="MousePointer" value="http://www.mamicode.com/0"/>
<param name="Enabled" value="http://www.mamicode.com/1"/>
<param name="Min" value="http://www.mamicode.com/0"/>
<param name="Max" value="http://www.mamicode.com/10"/>
</object>

</body>
</html>