2014年3月24日 星期一
Lab 14 Create Image using DOM
<html>
<head>
Click the button to call a photo<br />
<button onclick="build()">Try it</button>
<title>lab14</title>
<script>
function build()
{
myImg =document.createElement("IMG")
myImg.setAttribute("id","imageOne")
myImg.setAttribute("src","http://airsnarf.shmoo.com/airsnarf.jpg")
docBody = document.getElementsByTagName("body").item(0)
docBody.appendChild(myImg)
}
window.onload=build
</script>
</head>
<body>
<br />
</body>
</html>
Click the button to call a photo
lab14
<head>
Click the button to call a photo<br />
<button onclick="build()">Try it</button>
<title>lab14</title>
<script>
function build()
{
myImg =document.createElement("IMG")
myImg.setAttribute("id","imageOne")
myImg.setAttribute("src","http://airsnarf.shmoo.com/airsnarf.jpg")
docBody = document.getElementsByTagName("body").item(0)
docBody.appendChild(myImg)
}
window.onload=build
</script>
</head>
<body>
<br />
</body>
</html>
Click the button to call a photo
2014年3月22日 星期六
2014年3月17日 星期一
Lab 11 Regular Expression II
<html>
<head>
</head>
<body id="body">
<form action="javascript:void(0);" id="exampleForm">
<input type="password" id="examplePass" />
<input type="submit" />
</form>
</body>
<script>
document.getElementById("exampleForm").onsubmit = function() {
var passwordRegex = /-?\d+(\.\d+)?\,\-?\d+(\.\d+)?$/;
if (!passwordRegex.test(document.getElementById("examplePass").value)){
console.log("Regex didn't match");
var notify= document.getElementById("notify");
if(notify === null){
notify = document.createElement("p");
notify.textContent= "請輸入整數或小數,逗號,整數或小數";
notify.id ="notify";
var body = document.getElementById("body");
body.appendChild(notify);
}
}
};
</script>
</html>
<head>
</head>
<body id="body">
<form action="javascript:void(0);" id="exampleForm">
<input type="password" id="examplePass" />
<input type="submit" />
</form>
</body>
<script>
document.getElementById("exampleForm").onsubmit = function() {
var passwordRegex = /-?\d+(\.\d+)?\,\-?\d+(\.\d+)?$/;
if (!passwordRegex.test(document.getElementById("examplePass").value)){
console.log("Regex didn't match");
var notify= document.getElementById("notify");
if(notify === null){
notify = document.createElement("p");
notify.textContent= "請輸入整數或小數,逗號,整數或小數";
notify.id ="notify";
var body = document.getElementById("body");
body.appendChild(notify);
}
}
};
</script>
</html>
訂閱:
文章 (Atom)