這個代碼正確嗎?
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title>??
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>? ?
? <script type="text/javascript">??
? ? function openwindow(){
? ? ? ? ?if (confirm("打開新窗口")) {
? ? ? ?window.open('http//www.xianlaiwan.cn,''_blank','height=500,width=400','tolbar=no','menu bar=no',);
? ? ? ?else{
? ? ? ? ? ? ? alert("你選擇了取消");
? ? ? ? ? }
? }?
? ??
? ? // 新窗口打開時彈出確認框,是否打開
? ? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。? ??
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>
因為無法驗證,所以不知道有沒有碼對。
2018-12-28
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>編程練習</title>
<script type="text/javascript">
function rec()
{
var open=confirm("是否需要在新的窗口打開目標網站?");
if(open==true)
{
var url=prompt("請鍵入您即將在新窗口打開的網站網址:"," http://www.xianlaiwan.cn/");
if(url!=null)
{
window.open(url,'_blank','width=400,height=500');
}
else
{
alert("再見");
}
}
else
{
var url=prompt("請鍵入您即將在本窗口打開的網站網址:"," http://www.xianlaiwan.cn/");
if(url!=null)
{
window.open(url,'width=400,height=500');
}
}
}
</script>
</head>
<body>
<input type="button" name="button" onclick="rec()" value="跳轉到其他網站"/>
</body>
</html>
2018-12-28
你的confirm用法和前面課上所講的用法不一樣
2018-12-27
不對,無法運行