點擊沒反應
<!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 web = confirm("你是否要打開網站");
? ? ? ? if (web == true)
? ? ? ? {
? ? ? ? ? ? var url=prompt("請輸出網站","http://www.xianlaiwan.cn/");
? ? ? ? ? ? if (url!=null)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? window.open(url,"_blank","width=400,height=500");
? ? ? ? ? ? }
? ? ? ? ? ? else{
? ? ? ? ? ? ? ? alert("再見");
? ? ? ? ? ? }
? ? ? ? }
? ? else
? ? {
? ? ? ? alert("再見");
? ? }
? ? }
? ??
? ? // 新窗口打開時彈出確認框,是否打開
? ? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ??
? ??
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>
2021-04-27
var url=prompt("請輸出網站","http://www.xianlaiwan.cn/");
看看這一行是不是逗號有問題 我剛剛復制了 改了這里打開了
2021-04-27
<!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 web = confirm("你是否要打開網站");
? ? ? ? if (web == true)
? ? ? ? {
? ? ? ? ? ? var url=prompt("請輸入網址","http://www.xianlaiwan.cn/");
? ? ? ? ? ? if (url!=null)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? window.open('url','_blank','width=400,height=500');
? ? ? ? ? ? }
? ? ? ? ? ? else{
? ? ? ? ? ? ? ? alert("再見");
? ? ? ? ? ? }
? ? ? ? }
? ? else
? ? {
? ? ? ? alert("再見");
? ? }
? ? }
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>
我在你的代碼基礎上修改了部分,主要是
?if (web == true)
? ? ? ? {
? ? ? ? ? ? var url=prompt("請輸入網址","http://www.xianlaiwan.cn/");
? ? ? ? ? ? if (url!=null)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? window.open('url','_blank','width=400,height=500');
? ? ? ? ? ? }
這一段,記得中間的逗號之類的也要用英文寫。