Showing posts with label window. Show all posts
Showing posts with label window. Show all posts

Wednesday, December 17, 2008

修改gnome-terminal的默认窗口大小

原来打开时为80*24的尺寸,如果需要调整默认的大小,可按下操作:
$> sudo vi /usr/share/vte/termcap/xterm
找到下面这行
:co#80:it#8:li#24\
修改其中的80和24,分别为terminal的高和宽。
也可以用以下命令查看参数:
$> gnome-terminal --help-all

Saturday, October 11, 2008

HowTo set width/height/font/fontSize of vim window

" set the screen width and height, the same as set columns and lines
win 80 25
" columns width of the display
" set co=80
" lines number of lines in the display
" set lines=24
" For Mac OS X you can use something like this: >
set guifont=Monaco:h12

Tuesday, April 08, 2008

恢复HTML文件默认icon图标

也不知道系统安装了什么软件之后,所有的HTML/HTM文件图标全变成未关联的应用程序图标,相当难看
Google后得到如下解决方法:
在CMD命令行里依次输入以下4个命令:
C:>ASSOC .HTM=""
C:>ASSOC .HTM="htmlfile"
C:>ASSOC .HTML=""
C:>ASSOC .HTML="htmlfile"

Wednesday, April 02, 2008

load a track link when window.onunload

When close this window or leave this page will get request below, this trick may be cause bad user experience, and Opera will ignore it:
***.***.***.*** - - [02/Apr/2008:23:10:18 +0800] "GET /track.html?1207149018624 HTTP/1.1" 301 253


<script type="text/javascript">
window.onunload = function(){
var img = new Image(1,1), i = 0;
img.src = "http://www.test.com/track.html?" + (new Date()).getTime();
while(i < 1000000) i++ ; // for img src load
};
</script>


window.onbeforeunload will pop out a confirm dialog, so can't using onbeforeunload.

Friday, February 15, 2008

Translate selection text to chinese in new window

Firefox:
javascript:var dict=function(){var select=document.getSelection();var url='http://sh.dict.cn/search/?q='+select;window.open(url);return ;};dict();

闭包(closures)的写法:(function(){var q=String(window.getSelection());var url='http://sh.dict.cn/search/?q='+q;window.open(url);return;})();

IE7:
javascript:var dict=function(){var select=document.selection.createRange().text;var url='http://sh.dict.cn/search/?q='+select;window.open(url);return ;};dict();

上面function里最后面必须是return; (相当于是return undefined;)否则当前页面会被function return的结果重写,要防止结果重写,也可以将dict()方法调用包含到void操作符内:
void((function(){var q=String(window.getSelection());var url='http://sh.dict.cn/search/?q='+q;window.open(url);return false;})());
usage:
1. 新建一个书签,目标URL用上面的代码,IE会有个提醒,需要确认一下。
2. 在打开的网页里,如GOOGLE READER,要查某个词,选中此词。
3. 点击刚新建的书签(bookmarklet),IE会再次提醒。

Wednesday, January 30, 2008

window frames property test

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<HTML>
<HEAD>
<TITLE>A frameset document</TITLE>
</HEAD>
<FRAMESET cols="40%, 60%" name="fs" id="frs">
<FRAME src="fm1.html" frameborder="0" name="fmn1" id="fmi1"/>
<FRAME src="fm2.html" frameborder="0" name="fmn2" id="fmi2"/>
</FRAMESET>
</HTML>
debug under firebug console:
>>> window
Window frames.html
>>> window.frames
Window frames.html
>>> window.frames[0]
Window fm1.html
>>> window.frames[1]
Window fm2.html
>>> window.frames[1].id
# => undefined
>>> window.frames[1].src
# => undefined
>>> window.frames[1].name
"fmn2"
>>> document.getElementById('fmi1')
<frame id="fmi1" name="fmn1" frameborder="0" src="fm1.html">
>>> document.getElementById('fmi1').id
"fmi1"

Object window has name propery, but has no id and src properties, so window.frames[1].src is undefined, we can get src value throught top window's element object, such as cument.getElementById('fmi1').id

Monday, January 07, 2008

Windows cmd 命令行下 SVN 命令执行结果为乱码的解决方法

在系统属性-高级-环境变量[加在当前的用户变量里即可,不一定要全局环境里设置]:
添加一个值:
APR_ICONV_PATH=${subversion_install_dir}\iconv

另同时从网上看到个关于文件提交后显示乱码的问题(未碰到过),也一起写在这里以备所需:
在环境变量中加参数:
LANG=zh_CN.UTF8

Monday, October 22, 2007

window.location and document.location

window.location 和 window.location.herf 为可读写的属性,对此赋值可定向页面去指定的URL。
document.location 和 document.URL 等价,是可只读属性,并且推荐使用document.URL,document.location 已废弃。不过多数浏览器还是可以对document.location 和 document.location.href 赋值定向到新的URL,此做法不推荐使用。

Sunday, August 19, 2007

JavaScript window.getSelection usage example


<script type="text/javascript" language="javascript">
if (window.getSelection) {
// Mozilla
if (String(window.getSelection()))
return String(window.getSelection());
} else if (document.getSelection) {
// Opera? Netscape 4?
if (document.getSelection())
return document.getSelection();
} else {
// IE
if ( document.selection.createRange().text )
return document.selection.createRange().text;
}
</script>
//以下代码是只能用于IE
<input type="text" id="test" value="get the next character after current cursor? 可取中文字" size="60"><br/>
<input type="button" value="取当前光标的后一个字母" onclick="nextChar()"><br/>
<input type="text" value="取当前光标的位置" onclick="charPosition()"><br/>

<script type="text/javascript" language="javascript">
<!--
var s;
function nextChar()
{
document.getElementById('test').focus();
var sel = document.selection.createRange();
sel.moveStart("character",0);
sel.moveEnd("character",1);
s = sel.text.slice(-1);
alert("S = " + s);
}

function charPosition() {
var obj = window.event.srcElement;
var s=document.selection.createRange();
s.setEndPoint("StartToStart", obj.createTextRange())
var pos = s.text.length;
alert(pos);
obj.createTextRange().select();
alert(document.selection.createRange().text);
}
//-->
</script>