如下的,在iframe中可以用,但是需要改造成在普通页面下也用使用,,,,,页面调用:
<a href="javascript:void(0);" onclick="showModalDialog('在${arg.name}之后插入参数', '../development/insertArg.jsp?domain=${param.domain}&command=${param.command}&index=${status.index}&insertType=insertArgAfter', {height: 300});">在之后插入参数</a>源JS代码:
function $p(p, d) {
return p.document.getElementById(d);
}function showModalDialog(title, url, options) {
//alert("testsefes");
var dialog = $p(parent, "modalWindow");
//alert("1111111111");
if (dialog == null || dialog.style.display == "block") {
alert("333");
dialog.style.display = "none";
//alert("222222222");
return;
}
if (title) {
$p(parent, "title").innerHTML = title;
} else {
$p(parent, "title").innerHTML = "No title window";
} if (url) {
$p(parent, "modalIframe").src = 'common/loading.html?url=' + escape(url);
} else {
$p(parent, "modalIframe").src = 'common/loading.html';
} var opt = {
width :450,
height :500,
modal :true,
center :true,
left :0,
top :0
}; if (options) {
if (typeof (options.width) != "undefined" && options.width > 200) {
opt.width = options.width;
}
if (typeof (options.height) != "undefined" && options.height > 40) {
opt.height = options.height;
}
if (typeof (options.modal) != "undefined") {
opt.modal = options.modal;
}
if (typeof (options.center) != "undefined") {
opt.center = options.center;
}
if (typeof (options.left) != "undefined") {
opt.left = options.left;
}
if (typeof (options.top) != "undefined") {
opt.top = options.top;
}
} if (opt.center) {
var cHeight = parent.document.documentElement.clientHeight;
var cWidth = parent.document.documentElement.clientWidth;
if (cWidth < opt.width) {
opt.left = 0;
} else {
opt.left = (cWidth - opt.width) / 2;
}
if (cHeight < opt.height) {
opt.top = 0;
} else {
opt.top = (cHeight - opt.height) / 2;
}
} if (!opt.modal) {
$p(parent, "mask").style.display = "none";
} var dialogWindow = $p(parent, "modalDiv"), dialogContent = $p(parent,"modalContent");
dialogWindow.style.width = opt.width + "px";
dialogWindow.style.height = opt.height + "px";
dialogWindow.style.left = opt.left + "px";
dialogWindow.style.top = opt.top + "px";
dialogContent.style.width = (opt.width - 16) + "px";
dialogContent.style.height = (opt.height - 38) + "px";
dialog.style.display = "block";
}
<a href="javascript:void(0);" onclick="showModalDialog('在${arg.name}之后插入参数', '../development/insertArg.jsp?domain=${param.domain}&command=${param.command}&index=${status.index}&insertType=insertArgAfter', {height: 300});">在之后插入参数</a>源JS代码:
function $p(p, d) {
return p.document.getElementById(d);
}function showModalDialog(title, url, options) {
//alert("testsefes");
var dialog = $p(parent, "modalWindow");
//alert("1111111111");
if (dialog == null || dialog.style.display == "block") {
alert("333");
dialog.style.display = "none";
//alert("222222222");
return;
}
if (title) {
$p(parent, "title").innerHTML = title;
} else {
$p(parent, "title").innerHTML = "No title window";
} if (url) {
$p(parent, "modalIframe").src = 'common/loading.html?url=' + escape(url);
} else {
$p(parent, "modalIframe").src = 'common/loading.html';
} var opt = {
width :450,
height :500,
modal :true,
center :true,
left :0,
top :0
}; if (options) {
if (typeof (options.width) != "undefined" && options.width > 200) {
opt.width = options.width;
}
if (typeof (options.height) != "undefined" && options.height > 40) {
opt.height = options.height;
}
if (typeof (options.modal) != "undefined") {
opt.modal = options.modal;
}
if (typeof (options.center) != "undefined") {
opt.center = options.center;
}
if (typeof (options.left) != "undefined") {
opt.left = options.left;
}
if (typeof (options.top) != "undefined") {
opt.top = options.top;
}
} if (opt.center) {
var cHeight = parent.document.documentElement.clientHeight;
var cWidth = parent.document.documentElement.clientWidth;
if (cWidth < opt.width) {
opt.left = 0;
} else {
opt.left = (cWidth - opt.width) / 2;
}
if (cHeight < opt.height) {
opt.top = 0;
} else {
opt.top = (cHeight - opt.height) / 2;
}
} if (!opt.modal) {
$p(parent, "mask").style.display = "none";
} var dialogWindow = $p(parent, "modalDiv"), dialogContent = $p(parent,"modalContent");
dialogWindow.style.width = opt.width + "px";
dialogWindow.style.height = opt.height + "px";
dialogWindow.style.left = opt.left + "px";
dialogWindow.style.top = opt.top + "px";
dialogContent.style.width = (opt.width - 16) + "px";
dialogContent.style.height = (opt.height - 38) + "px";
dialog.style.display = "block";
}
解决方案 »
- 关于js 函数的一点疑问? 跪求解释
- 问一个火狐中取表中值的问题,急。。。。谢谢了
- 關閉彈出的小窗口怎麼寫?
- 怎么我读取不了cookie
- 请教:如何更改td的class?
- 一个select对象,我想选择其中一个后,在select对象后面显示一个text输入框!怎么实现?
- 当选择下拉列表框不同的值,立刻执行一段代码填充下一个表格?急求 100分
- 如何用javascript来获取异地网址的源代码???
- javascript中如何根据控件的Value来判断是什么类型的控件.
- js的事件源是一个属性吗
- 如何去掉new ActiveXObject("Excel.Application");的警告
- JavaScript 画图(画笔)不流畅怎么弄啊??
<div id="modalWindow" style="display: none;">
<div id="mask"></div>
<div id="modalDiv">
<div class="modalTitle"><span id="title">功能操作</span><a class="close" href="javascript:void(0);" onclick="closeModalDialog();" title="关闭"></a></div>
<div id="modalContent"><iframe src="common/loading.html" id="modalIframe" name="modalIframe" frameborder="0"></iframe></div>
</div>
</div>
楼主为什么要自己写一个showModalDialog呢,
直接使用javascript的showMoadlDialog来实现很简单呀。
参数传递也方便。而且现在Firefox下也已经支持它了。
随便搜了一下说明给你看看。
http://blog.chinaunix.net/u/18391/showart_114440.html