第一個(gè)要求能實(shí)現(xiàn),后兩個(gè)無法實(shí)現(xiàn),求大神!!
? ? 1新窗口打開時(shí)彈出確認(rèn)框,是否打開 //已經(jīng)實(shí)現(xiàn)
? ? 2通過輸入對(duì)話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
? ? 3打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
以下為代碼:
<body>
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
<script type="text/javascript">
? function openWindow(){
? ? var judge=confirm("是否打開新窗口");
? ? ?if( judge == true )
????{
????????function openWindow(){
????????????var score;
????????????score = prompt("請(qǐng)輸入打開新窗口的網(wǎng)址","");
????????????Window.open('score','_blank','width=400,height=500') ? ?
????????????// score為儲(chǔ)存用戶輸入網(wǎng)址的函數(shù)名,順便問一下如何設(shè)置默認(rèn)網(wǎng)址為http://idcbgp.cn/
????????????}
????}
????else
????{
????document.write("已取消新窗口的打開");
????}
} ?
</script>
</body>
看過很多其他人的, 感覺都沒有實(shí)現(xiàn)要求2的。希望大神幫忙解讀。。
2015-04-06
或者 精簡(jiǎn)代碼····將openWindow里面openWindow方法去掉···
function openWindow(){
? var judge=confirm("是否打開新窗口");
? if( judge == true ){
????????var score = prompt("請(qǐng)輸入打開新窗口的網(wǎng)址","http://idcbgp.cn");
? ? ? ? window.open(score,'_blank','width=400,height=500');
? ? }else{
? ? document.write("已取消新窗口的打開");
? ?}
? }?