由于最近项目需要,故对Js代码作出整理:
1. 怎样自动检测用户有没有安装realplayer的插件,并能自动安装它?
> > > > > > > > > > > > > > > > > > > >
在这里,你可以设置x、y的值来设定所固定层的位置,改变setTimeout("MoveLayer('AdLayer');", 20)中20的值为你希望调用MoveLayer()的时间间隔。还有要注意的是,使用的图片最好为透明背景的gif图,以使图片的背景颜色不至于遮住后面的的内容。
3.javascript树的Demo 源代码
文件结构如下
DemoTree
|------MyTree.js
|------tree,html
|------image(存放用到的相关图片)
MyTree.js 内容如下
--------------------------------------------------
var Icon = {
folderOpen: "folderOpen.gif",
folderClose: "folderClose.gif",
fileimage: "file.gif",
plus: "plus.gif",
minus: "minus.gif",
blank: "blank.gif"
}
//set the directory of the pictures
setImagePath = function(sPath) {
for(o in Icon){
tmp = sPath + Icon[o];
Icon[o] = new Image();
Icon[o].src = tmp;
}
}
window.Tree = [];
function MyTree(){
this.id = window.Tree.length;
window.Tree[this.id] = this;
this.target = "_self";
this.nodes = {0:{id:0, superID: -1, Text: null, nodeType: null, childrenNodes: new Array()}};
}
var tr = MyTree.prototype; // create a instence of the MyTree
tr.add = function(key, superid, text, nodetype){
this.nodes[key] = {id: key, superID:superid, Text: text, nodeType: nodetype, childrenNodes: new Array()};
var ch = this.getNode(superid).childrenNodes;
ch[ch.length] = this.nodes[key];
}
// get a certain node by id
tr.getNode = function(key){
if (typeof this.nodes[key] != "undefined")
{
return this.nodes[key];
}
return null;
}
//get a node's parent
tr.getParent = function(key){
if(this.getNode(key) != null){
var skey = this.getNode(key).superID;
if(typeof this.nodes[skey] != "undefined"){
return this.getNode(skey);
} else {
return null;
}
}else{
return null;
}
}
//the status of the children
tr.hasChildren = function(key){
return this.getNode(key).childrenNodes.length > 0
}
//get root
tr.getRoot = function(key) {
if(key == 0)
return this.getNode(key);
var par = this.getParent(key);
if (this.getNode(key).id == 0)
{
return this.getNode(key);
}
else
{
return this.getRoot(par.id);
}
}
//draw a node
tr.drawNode = function(key){
var html = "";
var node = this.getNode(key);
var rootID = this.getRoot(key);
var hc = this.hasChildren(key);
//html += '
html += ' \n';
if(hc){
var io = key == rootID.id;
html += ('
html += this.drawChild(key);
html += '
}
return html;
}
//draw indent
tr.drawIndent = function(key){
var s = ''
var ir = this.getRoot(key).id == key;
var node = this.getNode(key);
var hc = this.hasChildren(key);
if(this.getParent(key) != null)
s = hc ? '')+s;
p = this.getParent(p.id);
}
return s;
}
//draw a node's children nodes
tr.drawChild = function(key){
var node = this.getNode(key);
var html = "";
for(var i = 0; i < node.childrenNodes.length; i++){
html += this.drawNode(node.childrenNodes[i].id);
}
return html;
}
//
tr.openHandler = function(key){
var handler = document.getElementById("handler"+key);
var container = document.getElementById("container"+key);
var fimage = document.getElementById("image"+key);
if(container.style.display ==''){
container.style.display = 'none';
handler.src = Icon.plus.src;
fimage.src = Icon.folderClose.src;
}else{
container.style.display = '';
handler.src = Icon.minus.src;
fimage.src = Icon.folderOpen.src;
}
}
//
tr.openFolder = function(key){
}
tr.toString = function(key){
return this.drawChild(0);
}
-----------------------------------------
tree.html代码如下
-----------------------------------------
4.页面漂浮广告
<script>
document.write('<DIV id=mov6 style="POSITION: absolute; width: 10px; height: 10px"><OBJECT class;
interval = setInterval('changePos()', delay);
}
start();
</script>