确定->输入地址->转入地址;否则->提示错误->自动关闭窗口
function openWindow(){ if(confirm("是否打开新窗口?")){ var myint=prompt("输入你想访问的网页"); if(myint){ window.open(myint,'_blank'); } else{ alert("输入有误,本窗口自动关闭"); window.close(); } } else{ alert("你不想访问其他网站?"); window.close(); }}
function openWindow(){ if(confirm("是否打开新窗口?")){ var myint=prompt("输入你想访问的网页"); if(myint){ window.open(myint,'_blank'); } else{ alert("输入有误,本窗口自动关闭"); window.close(); } } else{ alert("你不想访问其他网站?"); window.close(); }}
2016-04-24
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>window.open</title>
<script type="text/javascript">
function Wopen(){
if(confirm("是否打开新窗口?")){
var myint=prompt("输入你想访问的网页");
if(true){
window.open(myint,'_blank');
}
else{
alert("你不想访问其他网站?");
window.close(); }
}
</script>
</head>
<body>
<input name="button" type="button" onClick="Wopen()" value="ok" / >
<input name="button" type="button" onClick="wclose()" value="cancel" / >
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
<script type="text/javascript">
function openWindow() {
var myhref = confirm("你确定要打开网址么?");
if (myhref == true) {
var score = prompt("请输入要打开的网址:");
if (score != null) {
window.open ('http://' + score,'_blank','width=400px,height=500px,menubar=no,toolbar=no');
}
else {
alert("取消成功");
}
}
else {
alert("成功返回")
}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
<script type="text/javascript">
window.onload=function openWindow(){
var str=prompt("请输入网址","http://");
if(str!=null){
window.open(str,'_blank');
}
else{
alert("输入错误");
window.close();
}
}
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>window.open</title>
<script type="text/javascript">
function Wopen(){
var ad=prompt("输入地址<要加协议,比如:http://>");
window.open(ad,'jarrem','_blank');
}
function wclose(){
window.close();
}
</script>
</head>
<body>
<input name="button" type="button" onClick="Wopen()" value="ok" / >
<input name="button" type="button" onClick="wclose()" value="cancel" / >
</body>
</html>
举报