qq_慕九州2005229
2020-01-02 14:57
<!DOCTYPE html>
<html>
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
<script type="text/javascript">
function openWindow() {
const s = confirm("是否打开");
if (s==true)
{
const t = prompt("请输入您要打开的网址:");
window.open(t,'_blank','width=600,height=500,menubar=no,toolbar=no');
}
else
{
return;
}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>

基本功能可以实现了。就是你没有默认打开网址,还有就是prompt消息对话框,别人点取消也会打开新网站。我这样写的,差不多,不过我没写else。
JavaScript入门篇
741604 学习 · 9869 问题
相似问题