<script type="text/javascript">
function contxt() //定義函數
{
alert("哈哈,調用函數了!");
}
</script>
</head>
<body>
<form>
<input type="button" value="點擊我" onclick=" contxt() " />
</form>
</body>
function contxt() //定義函數
{
alert("哈哈,調用函數了!");
}
</script>
</head>
<body>
<form>
<input type="button" value="點擊我" onclick=" contxt() " />
</form>
</body>
2016-03-11
<body>
<button type="button" onclick="alter(哈哈,調用函數了)">點擊我</button>
</body>
<button type="button" onclick="alter(哈哈,調用函數了)">點擊我</button>
</body>
2016-03-11
<script type="text/javacript">
document.write("我就是最棒的");
</script>
document.write("我就是最棒的");
</script>
2016-03-11
<!DOCTYPE HTML>
<html>
<head>
<title>js</title>
</head>
<body>
<script type="text/javascript">
document.write("helo");
document.getElementById("p1").style.color="blue";
</script>
</body>
</html>
<html>
<head>
<title>js</title>
</head>
<body>
<script type="text/javascript">
document.write("helo");
document.getElementById("p1").style.color="blue";
</script>
</body>
</html>
2016-03-10
function openWindow(){
if(confirm("是否打開新窗口?")){
var url=prompt("要打開的網站:");
console.log(url);
if(url!=null){
window.open(url,'width=400','height=500',"_blank","menubar=no","toolbar=no");
}else{
window.open('http://www.qq.com',"_blank","menubar=no","toolbar=no");
}
}
}
if(confirm("是否打開新窗口?")){
var url=prompt("要打開的網站:");
console.log(url);
if(url!=null){
window.open(url,'width=400','height=500',"_blank","menubar=no","toolbar=no");
}else{
window.open('http://www.qq.com',"_blank","menubar=no","toolbar=no");
}
}
}
<h2 id="con">javascript課程</h2>
<input type="button" value="改變寬高" onClick="cwh()" />
<script>
var con=document.getElementById("con");
//定義“改變寬高”的函數
function cwh() {
con.style.width="200";
con.style.height="300";
}
</script>
<input type="button" value="改變寬高" onClick="cwh()" />
<script>
var con=document.getElementById("con");
//定義“改變寬高”的函數
function cwh() {
con.style.width="200";
con.style.height="300";
}
</script>
score =prompt("請輸入你的成績:","80");
2016-03-10
function hidetext()
{
var mychar = document.getElementById("con");
document.getElementById("con").style.display = "none";
}
function showtext()
{
var mychar = document.getElementById("con");
document.getElementById("con").style.display = "block";
}
{
var mychar = document.getElementById("con");
document.getElementById("con").style.display = "none";
}
function showtext()
{
var mychar = document.getElementById("con");
document.getElementById("con").style.display = "block";
}
2016-03-10
mychar.style.color = "red";
mychar.style.backgroundColor = "#ccc";
mychar.style.width = "300px";
mychar.style.backgroundColor = "#ccc";
mychar.style.width = "300px";
2016-03-10