Tuesday, April 20, 2010

IE6中select组件与css中z-index的冲突

在Positioned Elements and OS Controls, Applets and Plug-ins这篇文章中,描述了当position为absolute一个DIV被拖到select组件上方的时候,在IE6中,select组件会透过DIV层显示出来,这并不是想要的效果,这个问题并非是一个bug,因为在IE6中,select元素是一个window控制组件,并不支持z-index属性,在IE7之后则开始支持z-index属性,更详细的说明可查看MSDN关于select的文档:
From Microsoft Internet Explorer 5 to Internet Explorer 6, This element is a windowed control and does not support the z-index attribute or zIndex property.
As of Internet Explorer 7, this element is windowless and supports the z-index attribute and the zIndex property. The SELECT element does not require a strict doctype to enable windowless functionality.
This element is an inline element.
This element requires a closing tag.

Friday, March 26, 2010

notice "var" keywords of javascript in IE8

当前测试只是针对IE8,没有测试之前IE版本,以下代码在firefox/chrome中会按预期一样正常运行,代码测试注意打开firebug或者是console查看输出:


<script type="text/javascript">
// window.a 设置一个属性a到window上
window.a = 1;
// 正常打印出a:1
window.console.log(a);
</script>



<script type="text/javascript">
// 必须在此分二块script来写,如果写在一块script标签内,都会正常执行
// 在同一个script代码块内,javascript会解析当前代码块中所有的变量(之前没有出现过的变量名),并且都为 undefined
// 在这里还没有执行到var a=2,a为 undefined
// 针对IE8: window.a 也被置为 undefined
// 其他浏览器: window.a前面代码中已经定义,所以这里还是原来的值:1,而非像IE8中一样为 undefined
window.console.log(a);
var a = 2; // 注意前面有个变量声明: var
window.console.log(a);
</script>



<script type="text/javascript">
window.console.log(a);
// 这里因为没有用var新定义变量,所以a即为window.a,只是对变量重新赋值,代码执行没有问题
a = 3; // 注意前面没有变量声明: var
window.console.log(a);
</script>

以上代码在firefox/chrome中执行结果为: 1 1 2 2 3
以上代码在IE8中执行结果为: 1 undefined 2 2 3

隐藏ubuntu命令行中运行gvim的警告信息

$> gvim
** (gvim:6676): CRITICAL **: gtk_form_set_static_gravity: assertion `static_gravity_supported' failed
** (gvim:6676): CRITICAL **: gtk_form_set_static_gravity: assertion `static_gravity_supported' failed
** (gvim:6676): CRITICAL **: gtk_form_set_static_gravity: assertion `static_gravity_supported' failed
** (gvim:6676): CRITICAL **: gtk_form_set_static_gravity: assertion `static_gravity_supported' failed
** (gvim:6676): CRITICAL **: gtk_form_set_static_gravity: assertion `static_gravity_supported' failed

每次运行看到这些警告很不爽,网上找了一下,发现是一个待修正的问题,暂时只能将错误重定向到个人目录的.xsession-errors中,重写一个gvim的命令,放在个人主目录~/bin下:

#!/bin/bash
## Execute gvim, sending X/gtk errors to the standard place.
exec /usr/bin/gvim $* > /dev/null 2>>$HOME/.xsession-errors