點(diǎn)擊沒(méi)反應(yīng)
<!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("你是否要打開(kāi)網(wǎng)站");
? ? ? ? if (web == true)
? ? ? ? {
? ? ? ? ? ? var url=prompt("請(qǐng)輸出網(wǎng)站","http://idcbgp.cn/");
? ? ? ? ? ? if (url!=null)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? window.open(url,"_blank","width=400,height=500");
? ? ? ? ? ? }
? ? ? ? ? ? else{
? ? ? ? ? ? ? ? alert("再見(jiàn)");
? ? ? ? ? ? }
? ? ? ? }
? ? else
? ? {
? ? ? ? alert("再見(jiàn)");
? ? }
? ? }
? ??
? ? // 新窗口打開(kāi)時(shí)彈出確認(rèn)框,是否打開(kāi)
? ? // 通過(guò)輸入對(duì)話框,確定打開(kāi)的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
? ? //打開(kāi)的窗口要求,寬400像素,高500像素,無(wú)菜單欄、無(wú)工具欄。
? ??
? ??
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2021-04-27
var url=prompt("請(qǐng)輸出網(wǎng)站","http://idcbgp.cn/");
看看這一行是不是逗號(hào)有問(wèn)題 我剛剛復(fù)制了 改了這里打開(kāi)了
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("你是否要打開(kāi)網(wǎng)站");
? ? ? ? if (web == true)
? ? ? ? {
? ? ? ? ? ? var url=prompt("請(qǐng)輸入網(wǎng)址","http://idcbgp.cn/");
? ? ? ? ? ? if (url!=null)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? window.open('url','_blank','width=400,height=500');
? ? ? ? ? ? }
? ? ? ? ? ? else{
? ? ? ? ? ? ? ? alert("再見(jiàn)");
? ? ? ? ? ? }
? ? ? ? }
? ? else
? ? {
? ? ? ? alert("再見(jiàn)");
? ? }
? ? }
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
我在你的代碼基礎(chǔ)上修改了部分,主要是
?if (web == true)
? ? ? ? {
? ? ? ? ? ? var url=prompt("請(qǐng)輸入網(wǎng)址","http://idcbgp.cn/");
? ? ? ? ? ? if (url!=null)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? window.open('url','_blank','width=400,height=500');
? ? ? ? ? ? }
這一段,記得中間的逗號(hào)之類的也要用英文寫(xiě)。