本文介绍xWin的JavaScript版本,该组件通过DIV结构实现窗口功能,旨在解决早期浏览器兼容性问题。代码已优化以兼容IE6.0及Firefox 1.5,并通过了XHTML Transitional与CSS验证。文章提供了具体的HTML结构示例及运行说明,展示了如何利用DIV属性定义窗口尺寸、位置及标题。
xWin JS版兼容性与验证说明
当前代码版本已修复已知问题,实现了对IE6.0和Firefox 1.5浏览器的兼容支持,并成功通过了XHTML Transitional标准验证以及CSS样式验证。
基于DIV的窗口实现方法
为满足上述验证标准,实现方式进行了调整,改为采用DIV元素来构建窗口结构。具体实施方法如下:
参考以下代码示例:
<div class="xWin">
<span class="xWinSetting"> width="200" top="270" left="140" title="我就是传说中那个超长的窗口标题"</span>
content
</div>完整HTML结构示例
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=gb2312" /> <title>xWin HTC Demo</title> <style type="text/css"> body { width:100%; height:100%; margin:0px; padding:0px; overflow:auto; } .xWin { position:absolute; cursor:default; border-width:2px; border-style:outset; padding:0px; font-size:12px; overflow:hidden; display:block; } .xWin .xWinSetting { display:none; } .xWin .xTitle { color:#FFFFFF; height:20px; display:block; } .xWin .xTitle input { background-color:transparent; color:#FFFFFF; border-width:0px; border-style:solid; height:20px; width:16px; line-height:20px; font-family:webdings; font-size:10px; margin:0px; padding:0px; text-align:center; float:right; display:block; } .xWin .xTitle .xWinTitleCloseButton { } .xWin .xTitle .xWinTitleMaxButton { } .xWin .xTitle .xWinTitleMinButton { } .xWin .xTitle .xWinTitleContent { color:#FFFFFF; font-size:12px; height:18px; line-height:20px; margin:0px; padding-left:3px; float:left; display:block; overflow:hidden; white-space:nowrap; text-align:left; cursor:default; } .xWin .xWinBody { margin:0px; background-color:#FFFFFF; color:#000000; padding:3px; font-size:12px; overflow:auto; position:relative; display:block; } .xShadow { position:absolute; display:block; background-Color:#000000; color:#FFFFFF; } </style> </head> <body> <div class="xWin" id="win1" > <span class="xWinSetting">width="400" height="400" top="300" left="100" title="我就是传说中那个超长的窗口标题"</span> 我就是传说中那个超长的窗口标题我就是传说 <div class="xWin" id="win30" > <span class="xWinSetting"> width="100" top="20" left="20" title="我就是传说中那个超长的窗口标题"</span> 中那个超长的窗口标题我就是传说中那个超长的窗口标题我就是传说中那个超长 </div> 的窗口标题我就是传说中那个超长的窗口标题我就是传说中那个超长的窗口标题我就是传说中那个超长的窗口标题 我就是传说中那个超长的 <div class="xWin" id="win31" > <span class="xWinSetting">width="100" top="40" left="40" title="我就是传说中那个超长的窗口标题" </span> 中那个超长的窗口标题我就是传说中那个超长的窗口标题我就是传说中那个超长 </div> 窗口标题我就是传说中那 个超长的窗口标题我就是传说中那个超长的窗口标题我就是传说中那个超长的窗口标题我就是传说中那 个超长的窗口标题我就是传说中那个超长的窗口标题 c 12345 </div> <div class="xWin" id="win2"> <span class="xWinSetting"> width="200" top="270" left="140" title="我就是传说中那个超长的窗口标题"</span> 我是窗口2 我是窗口2 我是窗口2 我是窗口2 更换标题 我是窗口2 我是窗口2 我是窗口2 我是窗口2 </div> win1 win2 win3 win4 <div id="ssss"></div> </body> </html>[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]