Showing posts with label DOCTYPE. Show all posts
Showing posts with label DOCTYPE. Show all posts

Sunday, October 12, 2008

如何禁止网页打开时IE弹出的安全警告

当直接双击打开一个有javascript代码的网页,IE会在窗口顶部出现一条黄色警告信息,内容如下所示:
为了有利于保护安全性,IE已限制此网页运行可以访问计算机的脚本或 ActiveX 控件。请单击这里获取选项...
要取消此信息,只要在网页源码顶部的!DOCTYPE声明下面加一行代码,即可禁止此警告条出现:
<!-- saved from url=(0022) -->
这句话的作用是让Internet Explorer 使用 Internet 区域的安全设置,而不是本地计算机区域的设置。
Reference:
http://zhidao.baidu.com/question/33183687.html?fr=qrl&fr2=query&adt=0_88
http://zhidao.baidu.com/question/3693592.html?fr=qrl

Wednesday, January 23, 2008

value of element.style must be string in Javascript


<!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>img</title>
</head>
<body>
<div id="img" style="position: absolute;">
<img border="0" alt="img" src="logo.gif"/>
</div>
<script type="text/javascript">
var img = document.getElementById('img');
img.style.left = 200;
img.style.top = 200 + "px";
</script>
</body>
</html>

当文档声明DOCTYPE没有的话,JS会正常的起效果,如果加上第一行的文档声明,则JS中的left就不会生效.
参考JavaScript Pocket Reference, 2nd Edition中第3章Style:
Synopsis
element.style
Properties
The Style object defines a large number of properties: one property for each CSS attribute defined by the CSS2 specification. The property names correspond closely to the CSS attribute names, with minor changes required to avoid syntax errors in JavaScript. Multiword attributes that contain hyphens, such as font-family are written without hyphens in JavaScript, and each word after the first is capitalized: fontFamily. Also, the float attribute conflicts with the reserved word float, so it translates to the property cssFloat.

The visual CSS properties are listed in the following table. Since the properties correspond directly to CSS attributes, no individual documentation is given for each property. See a CSS reference (such as Cascading Style Sheets: The Definitive Guide (O'Reilly), by Eric A. Meyer) for the meaning and legal values of each. Note that current browsers do not implement all of these properties.

All of the properties are strings, and care is required when working with properties that have numeric values. When querying such a property, you must use parseFloat( ) to convert the string to a number. When setting such a property you must convert your number to a string, which you can usually do by adding the required units specification, such as "px".