怎么彈出輸入對話框?
function openWindow()
? {
? ? var open=confirm("是否打開?");
? ? ?{
? ? ? ? ?if(open=true)
? ? ? ? ?{
? ? ? ? ? ?var url=prompt("確定打開嗎?","http://www.xianlaiwan.cn");
? ? ? ? ? ?if(url!=null)
? ? ? ? ? ?{
? ? ? ? ? ? ? ?window.open('http://www.xianlaiwan.cn','_blank','width=400,hight=500,menubar=0,toolbar=0');
? ? ? ? ? ?}
? ? ? ? ? ?else{alert("取消了");}
? ? ? ? ?}
? ? ? ? ?else{ alert("取消了")}
? ? ?}
? ? }
? ? ? ?
2016-07-07
function openWindow(){
? ? var msg=confirm("是否打開新窗口?");
? ? if(msg=true)
? ? ? ? {
? ? ? ? ? ? var score=prompt("請輸入網址","http://www.xianlaiwan.cn");
? ? ? ? ? ? if(score!=null && score!=""){
? ? ? ? ? ? window.open('http://www.xianlaiwan.cn','_blank','width=400px,height=500,menubar=no,toolbar=no');
? ? ? ? ? ? }
? ? ? ? }
? ? else
? ? ? ? {
? ? ? ? ? ? return false
? ? ? ? ? ? }
? ? }?
2016-07-07
<!DOCTYPE?html> <html> ????<head> ????????<meta?http-equiv="content-type"?content="text/html;?charset=utf-8"?/> ????????<title>test</title> ????</head> ????<body> ????????<button?type="submit"?id="btn">test</button> ????????<script?type="text/javascript"?charset="utf-8"> ?????????????var?btn?=?document.getElementById("btn"); ?????????????btn.onclick?=?function(){ ?????????????????var?btnOpen?=?confirm("是否要打開一個網站?"); ?????????????????if?(btnOpen==true){ ?????????????????????var?url?=?prompt("填入網址吧"); ?????????????????????if(url!=null){ ?????????????????????????window.open(url) ?????????????????????} ?????????????????????else{alert("放棄了填寫網址")} ?????????????????} ?????????????????else?{alert("點了否")} ?????????????}; ????????</script> ????</body> </html>2016-07-07
取消倒數第二個else。你可以看看w3school的promt()