手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >一个支持ff的modaldialog的js代码
一个支持ff的modaldialog的js代码
摘要:这是我看到的另一种方法了,虽然仍然不怎么样,不过了解一下也是不错的,目前代码不支持opera,我也没时间看能否支持=。=原地址:http:/...

这是我看到的另一种方法了,虽然仍然不怎么样,不过了解一下也是不错的,目前代码不支持opera,我也没时间看能否支持=。=

原地址:http://www.koders.com/javascript ... 882713BA1C7DD0.aspx

// 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);

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

【一个支持ff的modaldialog的js代码】相关文章:

一个特帅的展示图片的js+css

JavaScript通过Date-Mask将日期转换成字符串的方法

设为首页 加入收藏的js代码

一些有关检查数据的JS代码

实现DIV圆角的JavaScript代码

7个有用的jQuery代码片段分享

JQuery使用index方法获取Jquery对象数组下标的方法

让插入到 innerHTML 中的 script 跑起来的实现代码

JavaScript中的italics()方法的使用介绍

新页面打开实际尺寸的图片

精品推荐
分类导航