function openWindow(){
var mymessage = confirm("确定打开新窗口吗?");
if(mymessage = true){
var site = prompt("请输入网址:","http://www.imooc.com");
window.open(site,'_blank','width=400,height=500,menubar=no,toolbar=no')
}
}
var mymessage = confirm("确定打开新窗口吗?");
if(mymessage = true){
var site = prompt("请输入网址:","http://www.imooc.com");
window.open(site,'_blank','width=400,height=500,menubar=no,toolbar=no')
}
}
赋值主要是两种,一种是字符串,一种是数值,字符串可以理解为文本类型的,数值就是数值,字符串需要用“”,而数值不用。例如var mynum=69 和var mynum="69"就是不一样的,虽然最后的显示效果是一样的,但是实际上是不同的。
2016-08-18
<script type="text/javascript">
function contxt() //定义函数
{
alert("哈哈,调用函数了!");
}
</script>
</head>
<body>
<form>
<input type="button" value="点击我" onclick=" contxt() " />
function contxt() //定义函数
{
alert("哈哈,调用函数了!");
}
</script>
</head>
<body>
<form>
<input type="button" value="点击我" onclick=" contxt() " />
2016-08-18
<script type="text/javascript">
var score =80; //score变量存储成绩,初值为80
if(score>=60){
document.write("恭喜你,你及格了");
}
else{
document.write("很稀罕,继续努力!");
}
</script>
var score =80; //score变量存储成绩,初值为80
if(score>=60){
document.write("恭喜你,你及格了");
}
else{
document.write("很稀罕,继续努力!");
}
</script>
2016-08-18
<input type="button" value="改变颜色" onclick="changecolor()">
<input type="button" value="改变宽高" onclick="changeheight()">
<input type="button" value="隐藏内容" onclick="hidden()">
<input type="button" value="显示内容" onclick="unhidden()">
<input type="button" value="取消设置" onclick="unall()">
<input type="button" value="改变宽高" onclick="changeheight()">
<input type="button" value="隐藏内容" onclick="hidden()">
<input type="button" value="显示内容" onclick="unhidden()">
<input type="button" value="取消设置" onclick="unall()">
function changecolor()
{
var txt1=document.getElementById("txt");
txt1.style.color="red";
txt1.style.backgroundColor="blue";
}
{
var txt1=document.getElementById("txt");
txt1.style.color="red";
txt1.style.backgroundColor="blue";
}