wo ye xiang zhi dao
解决方案 »
- 谁能教下YUI3里面DOMContentLoaded如何使用?
- [急]lhgdialog4.1版本在js中父页面取值问题
- 一个input如何执行两个onclick事件呢
- 新手提问了 可能对你超级简单
- 输入提示功能,我的代码出错了
- 用复选按钮选择多条记录存入数据库
- JS中用XMLHTTP的问题,100分!
- 不用FORM是否可以提交表单
- 改变图片透明度:帮我看看这段脚本为什么老报错
- 怎样 去掉 在创建COM(ActiveX DLL/OCX)的时候出现的警告对话框?
- 在网上找了一个开源的JS幻灯片图片浏览,用到了AJAX,PHP,Javascript.哪位高人帮我改成JSP的。我只想在我的一个页面里用他。谢谢了。
- 简单问题,用JS怎么实现页面初始化时,就像网页按了F11的效果一样? 在线等!
function b(){
this.b1=function(){
alert(222);
};
}
b.prototype.b1 = function(){
alert(1111);
}; var b=new b();
b.b1();
a.js文件
-----------
function a(){
//完成某些操作
...//在这里我想调用某空方法,不污染空间。所以不能直接写b();然后在a.js中定义一个空的b();可以理解为这里触发某事件或者调用某方法
}aa.html文件
--------
<script src="a.js"></script>
<script>
//这里需要在a捕获在a()中触发的事件或者重载a()中这里调用的方法。完成某些功能
</script>
<a href="#" onclick="a();"></a>我现在就是用try{}catch(){}来实现的。想请问有没有更好的实现方式。
function b(){
if(typeof b1 == 'function')
b1();
}
function b1(){
}
</script>
<a href="#" onclick="b();">test </a> <br>
//优雅不?
事件触发是否是这样实现的呢?
this.b1();
} 直接调用b()而不是new对象的时候里面的this就是指的window对象了 就可以省略 即
function b(){
b1();
}
/////////////////////////////部门员工树///////////
function createDiv( obj, id ){
var closeDiv = document.createElement("div");
window.document.body.appendChild(closeDiv);
closeDiv.id = id + "_close";
closeDiv.style.position = "absolute";
closeDiv.style.textAlign = 'right';
closeDiv.style.zIndex = 100;
closeDiv.style.visibility = 'hidden';
closeDiv.style.borderColor = '#FFFFFF';
closeDiv.style.border = '0px';
closeDiv.style.borderColor = '#000000';
closeDiv.style.borderStyle = 'solid';
closeDiv.innerHTML = "<a href=javascript:_closeDiv('"+id+"'); class='btnCls2' title='关闭' ></a>";
var topDiv = document.createElement("div");
window.document.body.appendChild(topDiv);
topDiv.id = id;
topDiv.style.zIndex = 99;
topDiv.style.display = 'block';
topDiv.style.position = "absolute";
topDiv.style.backgroundColor = '#FFFFFF';
topDiv.style.border = '1px';
topDiv.style.borderColor = '#000000';
topDiv.style.borderStyle = 'solid';
topDiv.style.fontSize = '12px';
topDiv.style.padding = '0px';
topDiv.style.visibility = 'hidden';
topDiv.style.overFlow = 'true';
_moveDiv(obj, id);
}function _moveDiv(obj, id){ $(id).style.width= getClientWidth(obj) + "px";
$(id).style.height= getClientHeight(obj) + "px";
$(id+"_close").style.width= 21 + "px";
$(id+"_close").style.height= 18 + "px";
var x = 0;
var y = 0;
if(is_ie){
x= document.body.scrollLeft + obj.getBoundingClientRect().left;
y=document.body.scrollTop + obj.getBoundingClientRect().top + obj.clientHeight + 3;
$(id).style.filter = "alpha(opacity=100)";
}else if(is_moz){
x=document.body.scrollLeft + document.getBoxObjectFor(obj).x;
y=document.body.scrollTop + document.getBoxObjectFor(obj).y + obj.clientHeight + 3;
$(id).style.opacity = "1.0";
}
try{
$(id).style.left = x+ "px";
$(id).style.top = y+"px";
}catch(e){}
try{
$(id+"_close").style.left = (parseInt(x) + parseInt(getClientWidth(obj)) -22)+ "px";
$(id+"_close").style.top = (parseInt(y)+2)+"px";
}catch(e){}
}
function openDiv(obj, id){
if( $(id) == null ){
createDiv(obj, id);
_showDiv(id, true);
_showDiv(id+"_close", true);
}
else{
_showDiv(id, true);
_showDiv(id+"_close", true);
}
fixSelectBug(false);
}function _showDiv(id, isShow){
var x = $(id).style;
x.visibility = (isShow) ? 'visible':'hidden';
}
function _closeDiv(id){
_showDiv(id, false);
_showDiv(id+"_close", false);
fixSelectBug(true);
try{
this.afterClosed();//这里就我问的问题 } catch(exception){}
}
function setDivContext(id, context){
$(id).innerHTML = context;
}
var dhtmlTree_list = {};//树对象集合<Object{id 层编号,obj 表单对象,tree dhtmlTree对象(对象的属性方法请查阅官方文档)}>
dhtmlTree_list.size = 0;//集合大小
dhtmlTree_list.curIndex;//当前操作Object在集合中的下标
function getOrgEmp(obj){
var dhtmlTree = _getDhtmlTree(obj);
var div_id = dhtmlTree==null? new Date().getTime()+"_div" : dhtmlTree.id;
var tree_div_id = div_id+"_tree";
openDiv(obj, div_id);
if( $(tree_div_id) == null ){
setDivContext(div_id,"<div id='"+tree_div_id+"' style='OVERFLOW-x:auto;OVERFLOW-y:auto;width:"+getClientWidth(obj)+";height:"+getClientHeight(obj)+";'></div>");
var url = ajaxPath + "/OrgEmpTree.do";
var orgEmp_tree_obj=new dhtmlXTreeObject(tree_div_id,"100%","100%",0);
orgEmp_tree_obj.setImagePath(appPathTmp+"js/dhtmlxtree/codebase/imgs/csh_bluebooks/");
orgEmp_tree_obj.enableCheckBoxes(1);
orgEmp_tree_obj.enableThreeStateCheckboxes(true);
orgEmp_tree_obj.enableTreeImages(0);
orgEmp_tree_obj.setXMLAutoLoading(url);
orgEmp_tree_obj.loadXML(url);
orgEmp_tree_obj.attachEvent("onCheck",function(id, state){
if( state == "1" )
orgEmp_tree_obj.openAllItems(id);
else
orgEmp_tree_obj.closeAllItems(id);
});
var dhtmlTree = new Object();
dhtmlTree.id = div_id;
dhtmlTree.obj = obj;
dhtmlTree.tree = orgEmp_tree_obj;
dhtmlTree_list[dhtmlTree_list.size] = dhtmlTree;
dhtmlTree_list.curIndex = dhtmlTree_list.size;
dhtmlTree_list.size++;
try{
this.afterloaded();
} catch(exception){}
}
}
function _getDhtmlTree( obj ){
for(var i=0; i<dhtmlTree_list.size; i++){
if( dhtmlTree_list[i].obj === obj ){
dhtmlTree_list.curIndex = i;
return dhtmlTree_list[i];
}
}
return null;
}
var afterClosed = function(){};
function _closeDiv(id){
_showDiv(id, false);
_showDiv(id+"_close", false);
fixSelectBug(true);
afterClosed();
}var afterClosed = function(){
alert('sadsa');
};