JavaScript利用DOM给页面添加内容
自定义一个log函数,输出传入函数的对象或者信息.
Log.js
// JScript source code
function
log(category, message, object) {
// If this category is explicitly disabled, do nothing
if
(log.options[category + "Disabled
"]) return
;
// Find the container
var
id = category + "_log
";
var
c = document
.getElementById(id);
// If there is no container, but logging in this category is enabled,
// create the container.
if
(!c && log.options[category + "Enabled
"]) {
c = document
.createElement("div
");
c.id = id;
c.className = "log
";
document
.body.appendChild(c);
}
// If still no container, we ignore the message
if
(!c) return
;
// If timestamping is enabled, add the timestamp
if
(log.options.timestamp)
message = new
Date
() + ":
" + (message ? message : "");
// Create a element to hold the log entry
var
entry = document
.createElement("div
");
entry.className = category + "_message
";
if
(message) {
// Add the message to it
entry.appendChild(document
.createTextNode(message));
}
if
(object && typeof
object == "object
") {
entry.appendChild(log.makeTable(object, 0));
}
// Finally, add the entry to the logging container
c.appendChild(entry);
}
// Create a table to display the properties of the specified object
log.makeTable = function
(object, level) {
// If we've reached maximum recursion, return a Text node instead.
if
(level > log.options.maxRecursion)
return
document
.createTextNode(object.toString
());
// Create the table we'll be returning
var
table = document
.createElement("table
");
table.border = 1;
// Add a Name|Type|Value header to the table
var
header = docum
相关文档:
JDK6已经发布很久了,很早就听过他已经支持脚本语言了,不过一直没有时间尝试,今天偷闲试了一下,感觉不错。
javax.script包它是Java新增的操作脚本的工具包,
利用它我们可以对脚本语言进行操作(本例仅是针对javascript
)
1.用引擎直接解析脚本公式
Java代码
//创建脚本引擎管理器
Scri ......
第一种方法如下
if (typeof beforeReject != 'undefined' && beforeReject instanceof Function) {
beforeReject(nextStep);
}
第二种方法如下
if (对象名.方法名)
{
//方法存在
对象名.方法名();
}
第三种方法:
if(typeof(nl.onBlue)=="function")
{
//存在
}
......
以前做项目时候经常用到多行输入框字数的控制以及统计显示的情况,综合了几种情况后现在固定用了这个脚本。
例如 要输入描述textbox
<div>
<h3>
描述:</h3>
<asp:TextBox runat="server" ID="tbdesciption" Height="200px" TextMode="MultiLine" onkey ......