Showing posts with label Bug. Show all posts
Showing posts with label Bug. Show all posts

Sunday, December 19, 2010

comments bug on firefox


<body>
<!--

这段HTML注释代码因为中间多了2个连字符,在firefox中会导致解析出错,这段内容被做为正常的文本内容显示在浏览器中。
This entire comment -- will show in web browser

-->
</body>

Reference: (SGMLComment) Mozilla interprets a -- (two dashes in a row) inside of a comment or an include improperly

Tuesday, February 03, 2009

Javascript expression '\s'=='s' is true in ie6

在ie6中
var exp = '\s'=='s';
的结果返回为true.

Tuesday, December 23, 2008

IE6/IE7上ajax请求的一个bug

UTF-8编码的页面,在IE6/IE7中用ajax方式和普通直接访问方式请求此url,结果是不一样的:
http://localhost/test.php?q=测试中文

ajax: http://localhost/test.php?q=测试中文
服务器端收到的请求,其中的中文参数是以ISO-8859-1编码的(浏览器的默认编码方式),所以服务器端收到的参数其实是乱码的,所以ajax请求URL中的参数一定要经过encode,除了ie之外,其他浏览器测试下来都会自动url encode其中的参数。

非ajax: http://localhost/test.php?q=%E6%B5%8B%E8%AF%95%E4%B8%AD%E6%96%87
服务器端收到正常的UTF-8编码后的参数。

ie中空白渲染的问题

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<form action="test_submit" method="get" accept-charset="utf-8">
<input type="text" name="some_name" value="" id="name">
<div id="x" style="white-space:pre;">x xx x</div>
<div id="y">y yy y</div>
<p><input type="button" value="click here" onclick="document.getElementById('name').value=document.getElementById('x').innerHTML"></p>
<p><input type="button" value="click here" onclick="document.getElementById('name').value=document.getElementById('y').innerHTML"></p>
</form>
</body>
</html>

上面的例子在ie6/ie7中测试时可发现y组成的字符串,其中的空格被ie渲染过后,取到的innerHTML已经变为一个空格了,在firefox/safari上在渲染后看上去是只有一个空格,但innerHTML取到的还是与原码是保持一致的。

Sunday, October 26, 2008

RenderSupport Usage in Tapestry5

RenderSupport是在写组件中非常有用的一个service,主要用于提供对组件渲染的支持,可以用其导入css/javascript文件,最重要的一个功能是其可以为组件生成客户端HTML标签的唯一id。
要生成此客户端的id,可以用二个方法产生,一是RenderSupport.allocateClientId(String id),由自己指定一个id字符串,如果一个页面中包含多个相同组件,则第二个之后的组件会在此id后加上"_"和0开始的数字做为其id。
另外是用RenderSupport.allocateClientId(ComponentResources resources),resources会抽取其组件的id做为其客户端的id值。
举例写一个checkBoxes组件,需要提一点是不要分配"checkbox"做为组件的id,这个会导致server崩掉,Tapestry5的一个bug,还没有解决。

public class CheckBoxes {

@Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
private String value;

@Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
private String name;

@Parameter
private boolean checked;

@Inject
private Request request;

@Inject
private ComponentResources resources;

@Inject
private RenderSupport renderSupport;

@BeginRender
void begin(MarkupWriter writer) {
String id = renderSupport.allocateClientId("chk"); // don't use checkbox.
System.out.println(id);
Element checkbox = writer.element("input", "type", "checkbox", "name", name, "id", id, "value", value);
checkbox.attribute("checked", checked ? "checked" : null);
}

@AfterRender
void after(MarkupWriter writer) {
writer.end();
}

}

Tuesday, August 12, 2008

解决IE6的浮动元素的双倍边距问题

对一个div设置了float:left 和 margin-left:100px 那么在IE6中,这个bug就会出现。您只需要多设置一个display即可,代码如下:


div {float:left;margin:40px;display:inline;}

Reference:http://www.javaeye.com/news/3176

Wednesday, April 23, 2008

firefox bug when using iframe and javascript alert() function


<iframe src="http://localhost/perl/cgi.pl" height=1 width=1></iframe>

<script type="text/javascript" charset="utf-8">
alert('test');
window.location = "http://localhost/javascript/index.html";
</script>

以上代码在ie7和safari里调用的都会去请求iframe的src指向的URL,但在Firefox里这个动作却并不会执行,在server端不会收到这个GET请求。
必须在iframe之外加一些html标签,如img/body等才能使此iframe的src指向的请求被执行。如下所示:

<html>

<body>

<iframe src="http://localhost/perl/cgi.pl" height=1 width=1></iframe>

<script type="text/javascript" charset="utf-8">
alert('test');
window.location = "http://localhost/javascript/index.html";
</script>

</body>
</html>

Tuesday, March 04, 2008

IE bug: id and name in getElementById function


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> Test id and name property in IE7 </title>
</head>
<body>
<input name="t1"/> Input tag with name t1, IE7 will alert "INPUT"<br />
<a name="t1">Anchor t1, if remove input element, IE7 will alert "A"</a><br />
<div id="t1">div tag with id t1</div>

<script type="text/javascript">
alert(document.getElementById('t1').tagName);
</script>
</body>
</html>

Opera has the same problem.

Friday, September 21, 2007

[1071]Mysql::Error: Specified key was too long; max key length is 1000 bytes

在Windows XP下用Mysql5.1.20创建一个表索引碰到这个错误,错误号1071,表为GBK编码,MyISAM引擎。Google了一下,这个在Mysql5.2.0之前是个Bug,改用默认的Latin1字符集就可以避过这个问题,未验证,但是在CentOS 5.0下安装的Mysql5.0.45这个错误并不会发生,具体跟操作系统还有些关系。
错误原因说明及解决方法如下:
建立索引时,数据库计算key的长度是累加所有Index用到的字段的char长度后再按下面比例乘起来不能超过限定的key长度1000:
latin1 = 1 byte = 1 character
uft8 = 3 byte = 1 character
gbk = 2 byte = 1 character
举例能看得更明白些,以GBK为例:
CREATE UNIQUE INDEX `unique_record` ON reports (`report_name`, `report_client`, `report_city`);
其中report_name varchar(200), report_client varchar(200), report_city varchar(200)
(200 + 200 +200) * 2 = 1200 > 1000,所有就会报1071错误,只要将report_city改为varchar(100)那么索引就能成功建立。
如果表是UTF8字符集,那索引还是建立不了。