>  기사  >  웹 프론트엔드  >  ff의 modaldialog_javascript 기술을 지원하는 js 코드

ff의 modaldialog_javascript 기술을 지원하는 js 코드

WBOY
WBOY원래의
2016-05-16 19:18:191019검색

이것은 제가 본 또 다른 방법입니다. 아직 별로 좋지는 않지만 알아두면 좋습니다. 현재 코드는 오페라를 지원하지 않으며 지원될 수 있는지 확인할 시간이 없습니다 =. ="

원본 주소: http://www.koders.com/javascript... 882713BA1C7DD0.aspx


[Ctrl A 모두 선택 참고: 외부 J를 도입해야 하는 경우 실행하려면 새로 고쳐야 합니다
]<script> // Though "Dialog" looks like an object, it isn't really an object. Instead // it's just namespace for protecting global symbols. function Dialog(url, action, init) { if (typeof init == "undefined") { init = window; // pass this window object by default } if (document.all) { // here we hope that Mozilla will never support document.all var value = showModalDialog(url, init, // window.open(url, '_blank', // "resizable: no; help: no; status: no; scroll: no"); "resizable: yes; help: no; status: no; scroll: no"); if (action) { action(value); } } else { return Dialog._geckoOpenModal(url, action, init); } }; Dialog._parentEvent = function(ev) { if (Dialog._modal && !Dialog._modal.closed) { Dialog._modal.focus(); // we get here in Mozilla only, anyway, so we can safely use // the DOM version. ev.preventDefault(); ev.stopPropagation(); } }; // should be a function, the return handler of the currently opened dialog. Dialog._return = null; // constant, the currently opened dialog Dialog._modal = null; // the dialog will read it's args from this variable Dialog._arguments = null; Dialog._geckoOpenModal = function(url, action, init) { var dlg = window.open(url, "ha_dialog", "toolbar=no,menubar=no,personalbar=no,width=10,height=10," + "scrollbars=no,resizable=no"); Dialog._modal = dlg; Dialog._arguments = init; // capture some window's events function capwin(w) { w.addEventListener("click", Dialog._parentEvent, true); w.addEventListener("mousedown", Dialog._parentEvent, true); w.addEventListener("focus", Dialog._parentEvent, true); }; // release the captured events function relwin(w) { w.removeEventListener("focus", Dialog._parentEvent, true); w.removeEventListener("mousedown", Dialog._parentEvent, true); w.removeEventListener("click", Dialog._parentEvent, true); }; capwin(window); // capture other frames for (var i = 0; i < window.frames.length; capwin(window.frames[i++])); // make up a function to be called when the Dialog ends. Dialog._return = function (val) { if (val && action) { action(val); } relwin(window); // capture other frames for (var i = 0; i < window.frames.length; relwin(window.frames[i++])); Dialog._modal = null; }; }; Dialog("http://google.com",function(){alert('test')},null); </script>
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.