Wednesday, June 25, 2008

[转] Module Dialog In IE & FF

原文: http://www.zhangsichu.com/blogview.asp?Content_Id=50

本文实现了一个在IE和FF下都可以正常使用的ModuleDialog。
主要使用window.open方法打开Dialog。
使用window.onclick=function (){DialogWin.focus()};和event.cancelBubble = true;保证弹出窗口的Module样式。
详细内容:
ParentWindow
function OpenDialog()
{
if(window.document.all)//IE
{
//参数
var strPara = "dialogHeight:200px;dialogWidth:300px;help:off;resizable:off;scroll:no;status:off";
//传入的值
var strPassIn=window.document.getElementById("txtReturn").value;
//打开模态对话框
var strReturn=window.showModalDialog("ChildOpenWindow.htm",strPassIn,strPara);
//处理返回值
if(typeof(strReturn) != undefined)
{
window.document.getElementById("txtReturn").value=strReturn;
}
}
else//FireFox
{
//参数
var strPara = "dialogHeight:200px;dialogWidth:300px;help:off;resizable:off;scroll:no;status:off;modal=yes;dialog=yes";
var strPassIn=window.document.getElementById("txtReturn").value;

//注册事件
window.myAction=this;

//打开窗口
var DialogWin = window.open("ChildOpenWindow.htm","myOpen",strPara,true);

//传入参数
window.myArguments=strPassIn;

this.returnAction=function(strResult){
//处理返回结果
if(typeof(strResult) != undefined)
{
window.document.getElementById("txtReturn").value=strResult;
}
}

//处理打开窗口最上显示(不完美)
window.onclick=function (){DialogWin.focus()};
event.cancelBubble = true;
}
}

ChildWindow
function window_onload()
{
if(window.document.all)//IE
{
//对于IE直接读数据
var txtInput=window.document.getElementById("txtInput");
txtInput.value=window.dialogArguments;
}
else//FireFox
{
//获取参数
window.dialogArguments=window.opener.myArguments;
var txtInput=window.document.getElementById("txtInput");
txtInput.value=window.dialogArguments;
}
}

function OnOKClick()
{
//对于IE或者FireFox都需要设置returnValue进行返回值设定
var inputStr=window.document.getElementById("txtInput").value;
returnValue=inputStr;
window.close();
}

function window_onunload() {
//对于Firefox需要进行返回值的额外逻辑处理
if(!window.document.all)//FireFox
{
window.opener.myAction.returnAction(window.returnValue)
}
}
</script>
注册onload
<body language="javascript" onload="return window_onload()" onunload="return window_onunload()">

Monday, June 23, 2008

本地的html如何请求remote server的资源

本地的html文件内的ajax请求如果用异步的话, 通常readyState值返回为1或者是2, 而不是期望的4,
此时将ajax的异步改为同步即可, 此时get/post都是允许的.

Saturday, June 21, 2008

一个机器学习library: Lucene Mahout

Lucene最近新加了2个子项目Tika和Mahout, Tika前文介绍过, Mahout是一个机器学习的library, 包含: Classification, Clustering, Regression, Dimension reduction, ..., 可以看出lucene的野心

Apache 新出的工具文档解析器Tika

Apache 新出的工具文档解析器Tika, 可以支持ms系列, pdf, html, ..., 目前版本是0.1, 需要解析多种文档的同志们的福音啊

Friday, June 20, 2008

web.xml中的3种写法

web.xml中<url-pattern>的3种写法

a 完全匹配

<url-pattern>/test/list.do</url-pattern>

b 目录匹配

<url-pattern>/test/*</url-pattern>

c 扩展名匹配

<url-pattern>*.do</url-pattern>

servlet-mapping的重要规则:

容器会首先查找完全匹配,如果找不到,再查找目录匹配,如果也找不到,就查找扩展名匹配。
如果一个请求匹配多个"目录匹配",容器会选择最长的匹配。

css实现Tag云的两端对齐方式,

HTML Align
text-align:justify;text-justify:distribute-all-lines;

用css画个图标

用css画个图标出来 #com_a{ border-top:10px solid #FFFFCC;border-left:5px solid #FF3300;border-bottom:10px solid #FFFFCC;}

开源, 免费的安装程序制作工具, 可以支持Delphi脚本

下载地址: http://www.jordanr.dhs.org/isinfo.php

js简单继承的实现

function base() {
this.member = "dnnsun_Member";
this.method = function() {
window.alert(this.member);
}
}
function extend(child, b) {
b.call(child);
}
var child={
test:function(){
window.alert("in child");
window.alert(child.member);
}
};
extend(child, base);
window.alert(child.member);
window.alert(child.method);
child.test()

Sunday, June 15, 2008

getElementsByTagName返回值的问题

nodesList=getElementsByTagName返回的是一个类似NodeList的对象, 并且它的结果集动态的随元素的变化而变化, 例如将一个匹配的node从dom中remove时, 结果集将自动的remove此node,因此如果用
for (var i=0;i=nodesList.length;i++){
var node = nodesList[i];
node.parentNode.replaceNode(newNode,node);
}就遍历不完, 但是如果用for (var i=nodesList.length-1;i>=0;i--){...}就可以

Enjoy Euro 2008

Enjoy Euro 2008