<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
// document.write("i love");
function judy(){
alert("hi,judy")
}
//judy();
function rec(){
var message=confirm("你喜欢我吗");
if(message==true){
document.write("嗯,有眼光");
}else{
document.write("哼,我也不喜欢你");
}
}
//rec();
function promptDemo(){
var score=prompt("请输入分数");
if(score>90){
document.write("哇塞。学霸");
}
else if(80<score<90){
document.write("80---90");
}
else if(score<80){
document.write("我只笑笑不说话");
}
}
function Wopen(){
window.open('http://www.imooc.com','_self','width=300,height=200,menubar=no,toolbar=no,status=no,scollbars=yes')
}
function Wclose(){
var mywon=window.open('http://www.imooc.com','_blank','width=300,height=200,menubar=no,toolbar=no,status=no,scollbars=yes');
mywon.close();
}
function zongjie(){
var message=confirm("是否打开新窗口?");
if(message==true){
window.open('http://www.imooc.com','_blank','width=400,height=500,menubar=no,toolbar=no');
}else{
alert("取消打开新窗口");
}
}
function getId(){
var mychar=document.getElementById("con");
alert(mychar.innerHTML);
mychar.style.color="red";
mychar.style.backgroundColor="blue";
}
function hiddenContent(){
var mychar=document.getElementById("con");
mychar.style.display="none";
}
function showContent(){
var mychar=document.getElementById("con");
mychar.style.display="block";
}
</script>
</head>
<body>
<form>
<p id="con">i love javascript</p>
<input type="button" value="点击我" onclick="judy()">
<input type="button" value="再点一下" onclick="rec()">
<input type="button" value="点第三下" onclick="promptDemo()">
<input type="button" value="点击我,打开新窗口" onclick="Wopen()">
<input type="button" value="关闭窗口" onclick="Wclose()">
<input type="button" value="是否打开新窗口" onclick="zongjie()">
<input type="button" value="通过id获取值" onclick="getId()">
<input type="button" value="隐藏内容" onclick="hiddenContent()">
<input type="button" value="显示内容" onclick="showContent()">
</form>
</body>
</html>
javascript初级
最新推荐文章于 2024-08-13 22:07:58 发布