有提示確定與取消功能的彈出式窗的代碼_javascript技巧

來源:互聯網
上載者:User
我不知道這樣的功能叫什麼,找了好久也沒有找到,所以來找大家協助了,在此謝謝了。

我的目的是這樣的,就是在原有頁面基礎上,彈出一個新窗,同時原來的頁面偏灰色,並且不能操作,必須在彈出的新窗關閉後才能恢複原來視窗的操作。具體效果有點象lightbox和thickbox,我現在是想用thickbox,它可以實現這種舊頁面變灰的效果,但是沒有辦法實現舊頁面不能操作的問題。(要在firefox和ie下都能使用,ie的showModalDialog是可以實現這樣的目的,但是firefox下不能用啊)
<body onmousemove="moveIt();" onmouseup="end();" ondragstart="return false;" > <input type="button" value="關閉?" onclick="back.style.background='#333333';back.style.filter='alpha(opacity=40)';back.style.visibility='';wnd.style.display='inline';"> <script> var isDrag = false; function execCode(){ var newWin = window.open(); newWin.document.write(tt.value); } var oldX=0,oldY=0; function init(){ isDrag=true; oldX=event.x; oldY=event.y; } function end(){ isDrag=false; } function moveIt(){ if(isDrag){ var x =window.event.x; var y = window.event.y; hdl.parentNode.style.left = parseInt(hdl.parentNode.style.left.replace("px","")) + (x - oldX); hdl.parentNode.style.top = parseInt(hdl.parentNode.style.top.replace("px","")) + (y - oldY); oldX = x; oldY = y; } } </script> <div id="back" onclick="cancels.click();" onmousemove="moveIt();" onmouseup="end();" > </div> <div id="wnd" onmousedown="init();" onmousemove="moveIt();" onmouseup="end();" > <div id="hdl" ><b>視窗</b></div> <div >  <input type="button" value="確定" onclick="opener=null;window.close()"><input type="button" value="取消" id="cancels" onclick="back.style.visibility='hidden';wnd.style.display='none';"> </div> </div> </body>
[Ctrl+A 全選 注:如需引入外部Js需重新整理才能執行]
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.