| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 691 人关注过本帖
标题:[求助]如何用javascript生成如图无边框对话框
只看楼主 加入收藏
随缘小强
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2007-10-29
收藏
 问题点数:0 回复次数:3 
[求助]如何用javascript生成如图无边框对话框


如题,我参考了网上的一些例子,把这些图片切片放到表格里,然后用如下函数实现不了
<script language="javascript">
<!--
function showBox(Msg){
var popMenu,boxText,popX,popY,popWidth,popHeight;
popWidth=211;
popHeight=100;
popX=(screen.width-popWidth)/2;
popX=(screen.height-popHeight)/2;
popMenu=window.open("about","","");
boxText="<html>"+
"<table width=\"211\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">"+
"<tr>"+
"<td width=\"211\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"+
"<tr>"+
"<td height=\"23\"><img src=\"pic/box_top.jpg\" width=\"186\" height=\"23\" /></td>"+
"<td width=\"12%\"><img src=\"pic/box_top_right.jpg\" alt=\"关闭窗口\" width=\"25\" height=\"23\" onClick='self.close();'/></td>"+
"</tr>"+
"</table></td>"+
"</tr>"+
"<tr>"+
"<td height=\"58\" align=\"left\" valign=\"top\"><table width=\"100%\" height=\"132\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"pic/box_mid_bg.jpg\">"+
"<tr>"+
"<td width=\"8%\" rowspan=\"2\">&nbsp;</td>"+
"<td width=\"85%\" height=\"105\">"+Msg+"</td>"+
"<td width=\"7%\" rowspan=\"2\">&nbsp;</td>"+
"</tr>"+
"<tr>"+
"<td height=\"16\"><div align=\"center\"><img src=\"pic/box_submit.jpg\" width=\"39\" height=\"19\" /></div></td>"+
"</tr>"+
"</table></td>"+
"</tr>"+
"<tr>"+
"<td height=\"13\"><img src=\"pic/box_bottom.jpg\" width=\"211\" height=\"15\" /></td>"+
"</tr>"+
"</table>";
popMenu.moveTo(popX,popY);
popMenu.resizeTo(popWith,popHeight);
popMenu.writeln(boxText);
}
//-->
</script>

请问该如何来实现这个对话框
附件: 游客没有浏览附件的权限,请 登录注册
搜索更多相关主题的帖子: 边框 对话框 javascript popX 
2007-10-30 09:34
随缘小强
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2007-10-29
收藏
得分:0 
没人会么~~?
2007-10-30 16:32
ychg77speed
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2007-10-30
收藏
得分:0 
好代码呀 我也想学 哈
2007-10-30 17:44
随缘小强
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2007-10-29
收藏
得分:0 
回复:(随缘小强)[求助]如何用javascript生成如图无...

无边框窗口的实现我试了网上的思路:生成一个全屏的窗口再缩小移动,但是在IE里也实现不了,更不用考虑跨浏览器的代码了.
没办法,只能采用给对象定位的思路来实现,代码如下,但是还有个小小的缺点,就是在弹出窗口之后,不能锁定屏幕,用户还是可以进行其他操作,有哪位高手能补充下代码,使得弹出窗口在浏览器最前面,不点确定无法进行其他操作.谢谢了~~
<table width="200" border="1">
<tr>
<td><a href="#" onclick="showBox('你好');">点我</a></td>
</tr>
</table>
//此处以下为实现功能的js代码及html代码
<script language="javascript">
<!--
function showBox(msg){
var obj=document.getElementById("box");
var txtObj=document.getElementById("showmsg");
txtObj.innerHTML=msg;
var popX,popY,popWidth,popHeight;
popWidth=211; //表格的宽度,可以自定义,也可以由obj.width获取
popHeight=200; //表格的高度,可以自定义,但是无法由obj.heigth获取,所以最好自己定义一个
popX=(screen.width-popWidth)/2; //计算层的左上角X坐标,自定义或者其他算法均可
popY=screen.height/2-popHeight; //计算层的左上角Y坐标,自定义或者其他算法均可
obj.style.position="absolute";
obj.style.left=popX;
obj.style.top=popY;
obj.style.display="";
}

function hideBox(){
var obj=document.getElementById("box");
obj.style.display="none";
}
//-->
</script>
<table width="211" border="0" align="center" cellpadding="0" cellspacing="0" style="display:none" id="box">
<tr>
<td width="211"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="23"><img src="pic/box_top.jpg" width="186" height="23" /></td>
<td width="12%"><img src="pic/box_top_right.jpg" alt="关闭窗口" width="25" height="23" onClick=hideBox("box");></td>
</tr>
</table></td>
</tr>
<tr>
<td height="58" align="left" valign="top"><table width="100%" height="132" border="0" cellpadding="0" cellspacing="0" background="pic/box_mid_bg.jpg">
<tr>
<td width="8%" rowspan="2">&nbsp;</td>
<td width="85%" height="105"><div id="showmsg"></div></td>
<td width="7%" rowspan="2">&nbsp;</td>
</tr>
<tr>
<td height="16"><div align="center"><img src="pic/box_submit.jpg" width="39" height="19" onClick=hideBox("box");></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="13"><img src="pic/box_bottom.jpg" width="211" height="15" /></td>
</tr>
</table>
第一贴为效果图,有需要的,大家可以拿去按照需要裁减.调用的时候只需要如第一行,在<a>标记中使用onclick="showBox('你好');"即可

[此贴子已经被作者于2007-10-31 17:33:35编辑过]

2007-10-31 17:25
快速回复:[求助]如何用javascript生成如图无边框对话框
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017606 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved