打开网页
<html>
<head>
<title></title>
<script language="javascript">
function fun(thisurl){
window.open(thisurl) ;
}
</script>
</head>
<body onLoad="fun('index.html')">
</body>
</html>
控制窗口大小
<html>
<head>
<title></title>
<script language="javascript">
function fun(thisurl){
window.open(thisurl, "页面标题", "width=500, height=150, scrollbars=yes, resizeable=no") ;
}
</script>
</head>
<body onLoad="fun('index.html')">
</body>
</html>
Demo
<html>
<head>
<title></title>
<script language="javascript">
function fun(thisurl){
window.open(thisurl, "页面标题", "width=500, height=150, scrollbars=yes, resizeable=no") ;
}
</script>
</head>
<body>
<form action="" method="post" name="myform">
网址:<select name="url" onChange="fun(this.value)">
<option value="index.html">index</option>
<option value="3.html">3</option>
</select>
</form>
</body>
</html>
确认提示按钮
<html>
<head>
<title></title>
<script language="javascript">
function fun(){
if(window.confirm("确认删除?")){
alert("您选择的是'是'!") ;
} else {
alert("您选择的是'否'!") ;
}
}
</script>
</head>
<body>
<a href="#" οnclick="fun()">删除邮件</a>
</body>
</html>
重定向
<html>
<head>
<title></title>
<script language="javascript">
function fun(thisurl){
window.location = thisurl ; // 重定向
}
</script>
</head>
<body>
网站:<select name="url" onChange="fun(this.value)">
<option value="#">== 请选择要浏览的站点 ==</option>
<option value="http://www.baidu.com">百度</option>
<option value="http://blog.csdn.net/imwangjiping">wjp博客</option>
</select>
</body>
</html>
子窗口调用父窗口(子窗口操作父窗口中的一些对象)
父窗口
<html>
<head>
<title></title>
<script language="javascript">
function fun(thisurl){
window.open(thisurl, "页面标题", "width=500, height=150, scrollbars=yes, resizeable=no") ;
}
</script>
</head>
<body>
<input type="button" value="打开" onClick="fun('3.html')" >
</body>
</html>
子窗口
<html>
<head>
<title></title>
<script language="javascript">
function closeWin(){
window.close() ; // 关闭窗口
}
window.opener.location.reload() ; // 刷新页面
</script>
</head>
<body>
<h3><a href="#" οnclick="closeWin()" >关闭</a></h3>
</body>
</html>
子窗口调用父窗口(子窗口操作父窗口中的一些对象)Demo
父窗口
<html>
<head>
<title></title>
<script language="javascript">
function fun(thisurl){
window.open(thisurl, "页面标题", "width=500, height=150, scrollbars=yes, resizeable=no") ;
}
</script>
</head>
<body>
<form name="parentform">
<input type="button" value="选择信息" οnclick="fun('3.html')" >
<br>选择的结果:<input type="text" name="result">
</form>
</body>
</html>
子窗口
<html>
<head>
<title></title>
<script language="javascript">
function returnValue(){
var city = document.myform.city.value ; // 取出当前选择好的信息
var doc = window.opener.document ; // 取得父窗口文档
doc.parentform.result.value = city ; // 设置新内容
window.close() ;
}
</script>
</head>
<body>
<form name="myform">
选择: <select name="city">
<option value="北京">北京</option>
<option value="上海">上海</option>
<option value="深圳">深圳</option>
<option value="广州">广州</option>
<option value="天津">天津</option>
</select>
<input type="button" value="返回" οnclick="returnValue()">
</form>
</body>
</html>