為什么我的代碼沒有實現(xiàn)??
<!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 mymessage=confirm("是否在新窗口打開新的網(wǎng)站");
? ? if(mymessage==true)
? ? {
? ? ? ?document.write("是"); ? ?
? ? }
? ? else
? ? {
? ? ? ??
? ? ? ? document.write(“否”);
? ? }
? ? // 通過輸入對話框,確定打開的網(wǎng)址,默認為 http://idcbgp.cn/
? ? ?//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? var myname=prompt("請輸入你的網(wǎng)址");
? ? if(myname!=null)
? ? {
? ? ? window.open("http://idcbgp.cn/","width=400,height=500,toolbar=no,menubar=no");
? ? else
? ? {
? ? ? ? alert("關(guān)閉");
? ? }
? ? ? ??
? ? }
? ?
??
? } ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2016-06-05
function wopen(){
var xw=confirm('是否新建窗口?');
if(xw==true){
var url=prompt('請輸入網(wǎng)址', 'http://idcbgp.cn');
if(url){
window.open(url,'_blank','width=400,height=400;left=100,top=200');
}else{
document.write('你沒有打開新窗口');
}
}else{
document.write('你沒有打開新窗口');
? ? ? ? //wopen();
}
}
2016-06-05
你的代碼里面有幾個小問題,我該了一下,而且function函數(shù)里面的confirm和prompt兩個屬性的聯(lián)系你也沒有體現(xiàn),我修改后感覺兩個還是獨立運行的,并不是通過confirm的 是 否 ?來確定是否運行prompt。你可以參考下。要是能修改好,回我一下,謝謝
2016-06-05
第一個if語句中,要用confirm消息對話框。你用?document.write ?這個只能在網(wǎng)站頁面上顯示“是”“否”
2016-06-05
function openWindow(){
? ? ?var ope;
? ? ?// 新窗口打開時彈出確認框,是否打開
? ? ?ope=confirm("確認要打開新窗口?");
? ? ?if(ope==true){
? ? ? ? ?window.open('http://idcbgp.cn','_blank','width=400,height=500,menubar=no,toolbar=no');
? ? ?}
? ?}