js相关简单的界面互动弹窗----(入门1)
1. document.write("??"); 可用于直接向html界面输写内容
alert("??"): 不点击这个按钮就不能对网页进行任何操作(整人)
confirm用于选择动作.example:
function a(){
var mymessaget=confirm('你是男的?')
if(mymessaget==true)
{
document.write('man');
}
else{
document.write('woman');
}
prompt 消息对话框 example:
function rec(){
var score; //score变量,用来存储用户输入的成绩值。
score = prompt("请输入你的成绩:");
if(score>=90)
{
document.write("帅");
}
else if(score>=75)
{
document.write("666");
}
else if(score>=60)
{
document.write("洗洗睡吧");
}
else
{
document.write("你走吧,离开这里,去飞!");
}
}
open()可以查找一个已经存在或新建的浏览器窗口.
<script type="text/javascript">
function Wopen(){
window.open('www.baidu.com','_blank','width=300,height=200')
}
</script>
</head>
<body>
<input name="button" type="button" onClick="Wopen()" value="点击我,打开新窗口!" / >
</body>
exercise:
<!DOCTYPE html>
<html>
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function openWindow(){
var open1=confirm("确定你要新建一个窗口吗?");
if (open1==true) {
var url=prompt("通过输入对话框,确定打开的网址", "http://www.imooc.com");
}
if (url!=null) {
window.open(url, "_blank",
'width=400px,height=500px,height=500px,menubar=no,toolbar=no')
}
else {
alert("再见1!");
}
}
</script>
<head>
<body>
<h1>练练</h1>
<input type="button" name="button" onclick="openWindow()" value="请点击">
</body>
</head>

浙公网安备 33010602011771号