Home mail me! Syndicate this site using RSS

Archive for Javascript


jQuery 1.1.4 发布了!

jQuery 1.1.4发布了,作为1.1.x分支的最后一个版本,之后发布的版本就会是1.2版了。

从介绍来看,这个版本与1.1.3.1版的区别主要还是速度和性能上的大幅提升(特别是selector部分,提升非常大),以及BUG的修复。文件的大小似乎也慢慢开始大起来了,1.1.4版已加到21K了…

更多资料请访问jQuery官方网站:jQuery.com

Splitter without frame

splitter without frame

<html>
<head>
<script language="javascript">
<!--
var bInDrag = false;
var iSplitHeight = 20;
var iBrowserHeight = 400;
 
function initDrag(obj) {
	bInDrag = true;
	obj.setCapture();
}
 
function freeDrag(obj) {
	bInDrag = false;
	obj.releaseCapture();
}
 
function doDrag() {
	var iMoveHeight = 0;
	if (bInDrag) {
		iMoveHeight = event.clientY - document.getElementById('splitLine').style.pixelTop;
		document.getElementById('head').style.pixelHeight += iMoveHeight;
		document.getElementById('splitLine').style.pixelTop = document.getElementById('head').style.pixelHeight + (iSplitHeight/2);
		document.getElementById('foot').style.pixelTop += iMoveHeight;
		document.getElementById('foot').style.pixelHeight = iBrowserHeight - document.getElementById('foot').style.pixelTop;
	}
}
-->
</script>
<style type="text/css">
<!--
body {
	margin-left: 0px; margin-top: 0px;
}
-->
</style>
</head>
<body>
<div id="head" style="overflow:auto; height:100">
<table width="100%" height="100%" border="1" cellspacing="0" cellpadding="0">
<tr valign="top">
	<td>
		fggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
	</td>
	<td>&nbsp;</td>
</tr>
</table>
</div>
 
<div id="splitLine" height="20">
<hr onmousedown="initDrag(this);" onmouseup="freeDrag(this);" onmousemove="doDrag();" style="cursor:row-resize" color="#c6d7ff" noShade size="5">
</div>
 
<div id="foot" style="overflow:auto; height:300">
<table width="100%" height="100%" border="1" cellpadding="0" cellspacing="0">
<tr valign="top">
	<td>
		fgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
		fgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg<br>
	</td>
	<td>gggggggggggggggggg</td>
</tr>
</table>
</div>
</body>
</html>

[老文章]设置一行颜色的效果

<html>
<head>
<script language="javascript">
<!--
/**
* 用于标记已点击的行
*
* @access public
* @var  integer
*/
var oldRowNum = null;
 
/**
* 改变行颜色
*
* 实现原理:点击一行后,则标记该行已点击过,这样触发over或out事件的时候就不设置颜色了。
*
* @access  public
* @param  object  [theObject] 产生事件的那一行的对象
* @param  integer  [theRowNum] 行数
* @param  string  [theAction] 事件名称,取值为:over, out, click
* @param  string  [theDefaultColor] 默认的颜色
* @param  string  [theNewColor] 要设置的颜色
* @return  void
*/
function changeRowColor(theObject, theRowNum, theAction, theDefaultColor, theNewColor) {
 var newColor = null;
 
 if (theAction == 'over') {
  // onMouseOver事件
  if (typeof(oldRowNum) == 'undefined' || oldRowNum != theRowNum) {
   newColor = theNewColor;
  }
 } else if (theAction == 'out') {
  // onMouseOut事件
  if (typeof(oldRowNum) == 'undefined' || oldRowNum != theRowNum) {
   newColor = theNewColor;
  }
 } else if (theAction == 'click') {
  // onClick事件
  newColor = theNewColor;
  // 获取color_table对象
  var theTable = document.getElementById('color_table');
  // 获取color_table对象的所有tr对象
  var theRows = theTable.getElementsByTagName('tr');
  // 循环清除color_table这个表格里的所有行的颜色
  for (var i = 0; i < theRows.length; i++) {
   theRows[i].style.backgroundColor = theDefaultColor;
  }
  if (typeof(oldRowNum) == 'undefined' || oldRowNum != theRowNum) {
   // 标记当前行
   oldRowNum = theRowNum;
  } else {
   // 清空标记
   oldRowNum = null;
  }
 }
 
 if (newColor) {
  theObject.style.backgroundColor = newColor;
 }
}
 
//-->
</script>
</head>
<body>
<table id="color_table" border="1" width="300">
<tr onmouseover="changeRowColor(this, 1, 'over', 'white', 'orange');" onmouseout="changeRowColor(this, 1, 'out', 'white', 'white');" onmousedown="changeRowColor(this, 1, 'click', 'white', 'red');">
 <td>aa</td>
 <td>bb</td>
</tr>
<tr onmouseover="changeRowColor(this, 2, 'over', 'white', 'orange');" onmouseout="changeRowColor(this, 2, 'out', 'white', 'white');" onmousedown="changeRowColor(this, 2, 'click', 'white', 'red');">
 <td>aa</td>
 <td>bb</td>
</tr>
</table>
</body>
</html>

[老文章]PHP & XUL

很早就知道XUL是什么东西,但一直未用过,直到今天在David Sklar的BLOG上看到这篇关于XUL的文章(Creating Rich Applications with Mozilla, XUL, and AMP Technology)。

一、什么是XUL?

XUL即XML-based User Interface Language的缩写,是一种基于XML的界面设计语言,提供了各种各样的元件(elements)和物件(widgets)。它可以在 Mozilla 家族的所有产品中运行。

其实就跟微软大势宣扬的XAML一样,未来没有C/S或者B/S可言。至于XUL和XAML这两者谁效仿谁,就不是我们这些最终用户该研究的了:)
Read more…