<!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("是否打開(kāi)");
???????????if?(s==true)
????????{
????????????const?t?=?prompt("請(qǐng)輸入您要打開(kāi)的網(wǎng)址:");
????????????window.open(t,'_blank','width=600,height=500,menubar=no,toolbar=no');
????????}
????????else
????????{
????????????return;
????????}
???????}
????</script>
</head>
<body>
<input?type="button"?value="新窗口打開(kāi)網(wǎng)站"?onclick="openWindow()"?/>
</body>
</html>
2020-01-03
基本功能可以實(shí)現(xiàn)了。就是你沒(méi)有默認(rèn)打開(kāi)網(wǎng)址,還有就是prompt消息對(duì)話框,別人點(diǎn)取消也會(huì)打開(kāi)新網(wǎng)站。我這樣寫(xiě)的,差不多,不過(guò)我沒(méi)寫(xiě)else。