JavaScript实现类似Excel功能
//复制所选表格的数据到剪贴板 作者:xx
function copyData(){
var content = "";
var tbl = getTbl();
//获取所选的所有数据
for(j = start_Row; j <= end_Row; j++)
{
for(i = start_Col; i <= end_Col; i++)
{
content += (tbl.rows[j].cells[i].childNodes[0].value);
if(i != end_Col) content += String.fromCharCode(9);
}
content += "\n";
}
try
{
//赋值到剪贴板
clipboardData.setData('text',content);
}catch(e)
{
alert('error:' + e);
}
}
相关文档:
定义变量
var test=10;
使用对象属性
可以使用 . 操作符获得属性,也可以使用数组下标获得,比如
for(var prop in document)
document.write(document[prop]+"<br>");
With 声明对象,之后再用到对象就不必声明了
with(document){
write("Hello World<br>标题: ");
write(title);
}
常用对象 ......
第一题
(function(){
return typeof arguments;
})();
//问自动执行函数会返回什么值
// 就是考Arguments对象的typeof
// 看平时用firebug多不多了……
第二题
var f = function g(){ return 23; };
typeof g();
//问最后一行的执行结果
//根据标准,命名函数表达式的函数名只对函数 ......
to make a note that I love JavaScript. This article is only meant for some fun, and for us to be aware of some its short-comings.
1. The Name. JavaScript is NOT Java
We'll start with a fun jab at the name choice. While it was originally called Mocha, and then LiveScript, it was later changed to J ......
选择元素:document.getElementsByTagName,document.getElementsById,document.getElementsByName。
firstChild,lastChild,nextSibling,previousSibling
创建元素:document.createElement(),appendChild();
删除元素:removeC ......