写的第一个较有意义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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>javascript</title>
<script language="javascript">
document.onclick=function ()
{
var div=document.createElement("div");
div.style.width="600";
div.style.height="50";
div.innerHTML="Pleasure to meet you!";
div.style.backgroundColor="#fdadcc";
document.body.appendChild(div);
}
</script>
</head>
<body>
</body>
</html>
相关文档:
scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetL ......
<mce:script language=javascript><!--
var a=0;
// --></mce:script>
<?php
function func1()
{
$t="a=a+1;";
return $t."alert(a)";
}
?>
<?php
echo "<input type=button value='Sure' onclick=\"".func1()."\">";
?> ......
//总记录数
function sumRecord()
{
var conn= Server.CreateObject("ADODB.connection");
var rs= Server.CreateObject("adodb.recordset");
conn.open("PROVIDER=SQLOLEDB;DATA SOURCE=127.0.0.1;UID=sa;PWD=123456;DATABASE=test");
var sql = "select count(*) as RecordCount from baoming";
rs.open(sql, ......
//系统信息获取
function getSysInfo(){
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
//CPU信息
var cpu = new Enumerator (service.ExecQuery("SELECT * from Win32_Processor")).item();
var cpuType=cpu.Name,h ......
http://code.google.com/p/update-javascript-trim/
常见的写法为:
function trim(s){
return s.replace(/^\s+|\s+$/g, '');
}
优化后trim函数的代码如下:
function trim(str) {
str = str.replace(/^\s+/g, '');
for(var i = str.length - 1; i >= 0; i--){
if(!/^\s$/.test(str.substr(i,1) ......