慕田峪146999
2020-05-23 15:16
<input name="button" type="button" onclick="openy()" value="点击我" /> <script> function openy(){ var his = confirm("是否进入"); if(his==true){ var bottyr = prompt("请输入正确的网址:"); if(bottyr){ window.open(bottyr,'_blank'); }else{ window.open('https://www.imooc.com/code/412','_blank'); } }else{ document.write("谢谢光临"); } } </script>
随便输入正确网址,然后就可以直接跳过去了。
按题目的话自己改成默认网址,然后条件改成
(bottyr == "")
<!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 mymessage= confirm("确认打开新网页吗");
function myopen()
{ window.open('http://www.imooc.com','_blank','width=400,height=500,menubar=no,toolbar=no,status=no,scrollbars=yes');
}
if (mymessage==true)
{
myopen();
}
}
</script>
</head>
你这写代码的风格有点emmmm,就有点看不懂你在写什么?
<!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 message = confirm("是否打开网页?");
if (message == true) {
window.open('http://www.imooc.com','_blank', 'height=500, width=400, menubar=no, toolbar=no');
}
else {
document.write("do not open.");
}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>
JavaScript入门篇
739817 学习 · 9566 问题
相似问题