A javascript code _ javascript technique that supports ff modaldialog

Source: Internet
Author: User
One js Code that supports ff modaldialog. This is another method I have seen. Although it is still not very good, it is also good to understand. Currently, the Code does not support opera, I don't have time to check whether = is supported. =

Original address: http://www.koders.com/javascript... 882713BA1C7DD0. aspx

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 (u Rl, '_ 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 () ;}}; // shocould 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
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.